From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Jan 13 11:13:26 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 11:13:26 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Jan 13 11:13:26 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Jan 13 11:13:26 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 13 11:13:26 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 11:13:26 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 13 11:13:26 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Fri Jan 13 11:13:26 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Jan 13 11:13:26 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 11:13:26 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Fri Jan 13 11:13:26 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 11:13:26 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Jan 13 11:13:26 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Fri Jan 13 11:13:26 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Fri Jan 13 11:13:26 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Jan 13 11:13:26 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 11:13:26 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Fri Jan 13 11:13:26 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 11:13:26 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 13 11:13:26 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 11:13:26 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 13 11:13:26 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 13 11:13:26 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 11:13:26 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Fri Jan 13 11:13:26 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 11:13:26 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Fri Jan 13 11:13:27 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 11:13:27 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Fri Jan 13 11:13:27 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Jan 13 11:13:27 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 11:13:27 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Jan 13 11:13:27 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 11:13:27 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Jan 13 11:13:27 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 11:13:27 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Fri Jan 13 11:13:27 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 11:13:27 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Fri Jan 13 11:13:27 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 11:13:27 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 11:13:27 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Fri Jan 13 11:13:27 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 11:13:27 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Fri Jan 13 11:13:27 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 11:13:27 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Fri Jan 13 11:13:27 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 11:13:27 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Fri Jan 13 11:13:27 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Jan 13 15:13:58 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 15:13:58 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Jan 13 15:13:58 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Jan 13 15:13:58 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 13 15:13:58 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 15:13:58 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 13 15:13:58 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Fri Jan 13 15:13:58 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Jan 13 15:13:58 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 15:13:58 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Fri Jan 13 15:13:58 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 15:13:58 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Jan 13 15:13:58 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Fri Jan 13 15:13:58 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Fri Jan 13 15:13:58 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Jan 13 15:13:58 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 15:13:58 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Fri Jan 13 15:13:58 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 15:13:58 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 13 15:13:58 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 15:13:58 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 13 15:13:58 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 13 15:13:58 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 15:13:58 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Fri Jan 13 15:13:58 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0001.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 15:13:58 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Fri Jan 13 15:13:58 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 15:13:58 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Fri Jan 13 15:13:58 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Jan 13 15:13:58 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 15:13:58 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Jan 13 15:13:58 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 15:13:58 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Jan 13 15:13:58 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 15:13:58 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Fri Jan 13 15:13:58 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 15:13:58 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Fri Jan 13 15:13:58 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 15:13:58 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 15:13:59 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Fri Jan 13 15:13:59 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 15:13:59 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Fri Jan 13 15:13:59 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0001.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 15:13:59 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Fri Jan 13 15:13:59 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 15:13:59 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Fri Jan 13 15:13:59 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0001.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Jan 13 15:21:20 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 15:21:20 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Jan 13 15:21:20 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Jan 13 15:21:20 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 13 15:21:20 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 15:21:21 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 13 15:21:21 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Fri Jan 13 15:21:21 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Jan 13 15:21:21 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 15:21:21 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Fri Jan 13 15:21:21 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 15:21:21 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Jan 13 15:21:21 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Fri Jan 13 15:21:21 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Fri Jan 13 15:21:21 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Jan 13 15:21:21 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 15:21:21 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Fri Jan 13 15:21:21 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 15:21:21 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 13 15:21:21 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 15:21:21 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 13 15:21:21 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 13 15:21:21 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 15:21:21 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Fri Jan 13 15:21:21 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0002.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 15:21:21 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Fri Jan 13 15:21:21 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 15:21:21 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Fri Jan 13 15:21:21 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Jan 13 15:21:21 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 15:21:21 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Jan 13 15:21:21 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 15:21:21 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Jan 13 15:21:21 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 15:21:21 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Fri Jan 13 15:21:21 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 15:21:21 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Fri Jan 13 15:21:21 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 15:21:21 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 15:21:21 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Fri Jan 13 15:21:21 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 15:21:21 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Fri Jan 13 15:21:21 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0002.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 15:21:21 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Fri Jan 13 15:21:21 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 15:21:21 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Fri Jan 13 15:21:21 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0002.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Jan 13 16:00:53 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0003.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0003.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Fri Jan 13 16:00:54 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0003.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Jan 13 20:01:51 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 20:01:51 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Jan 13 20:01:51 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Jan 13 20:01:51 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 13 20:01:51 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 20:01:51 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 13 20:01:51 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Fri Jan 13 20:01:51 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Jan 13 20:01:51 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 20:01:51 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Fri Jan 13 20:01:51 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 20:01:51 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Jan 13 20:01:51 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Fri Jan 13 20:01:51 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Fri Jan 13 20:01:51 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Jan 13 20:01:51 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 20:01:51 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Fri Jan 13 20:01:52 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 20:01:52 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 13 20:01:52 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 20:01:52 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 13 20:01:52 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 13 20:01:52 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 20:01:52 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Fri Jan 13 20:01:52 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0004.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 20:01:52 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Fri Jan 13 20:01:52 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 20:01:52 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Fri Jan 13 20:01:52 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Jan 13 20:01:52 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 20:01:52 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Jan 13 20:01:52 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 20:01:52 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Jan 13 20:01:52 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 20:01:52 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Fri Jan 13 20:01:52 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 20:01:52 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Fri Jan 13 20:01:52 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 20:01:52 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 20:01:52 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Fri Jan 13 20:01:52 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 20:01:52 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Fri Jan 13 20:01:53 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0004.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 20:01:53 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Fri Jan 13 20:01:53 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 13 20:01:53 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Fri Jan 13 20:01:53 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0004.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Jan 14 08:02:27 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0005.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0005.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sat Jan 14 08:02:29 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0005.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Jan 14 12:00:52 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 12:00:52 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Jan 14 12:00:52 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Jan 14 12:00:53 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 14 12:00:53 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 12:00:53 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 14 12:00:53 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sat Jan 14 12:00:53 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Jan 14 12:00:53 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 12:00:53 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Sat Jan 14 12:00:53 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 12:00:53 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Jan 14 12:00:53 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sat Jan 14 12:00:53 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Sat Jan 14 12:00:53 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Jan 14 12:00:53 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 12:00:53 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Sat Jan 14 12:00:53 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 12:00:53 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 14 12:00:53 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 12:00:53 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 14 12:00:53 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 14 12:00:53 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 12:00:53 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Sat Jan 14 12:00:53 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0006.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 12:00:53 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Sat Jan 14 12:00:53 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 12:00:53 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Sat Jan 14 12:00:53 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Jan 14 12:00:53 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 12:00:53 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Jan 14 12:00:53 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 12:00:53 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Jan 14 12:00:53 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 12:00:53 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Sat Jan 14 12:00:53 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 12:00:53 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Sat Jan 14 12:00:53 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 12:00:53 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 12:00:53 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Sat Jan 14 12:00:53 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 12:00:53 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sat Jan 14 12:00:53 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0006.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 12:00:53 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Sat Jan 14 12:00:53 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 12:00:53 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sat Jan 14 12:00:53 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0006.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Jan 14 16:00:49 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 16:00:49 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Jan 14 16:00:49 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Jan 14 16:00:49 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 14 16:00:49 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 16:00:49 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 14 16:00:49 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sat Jan 14 16:00:49 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Jan 14 16:00:49 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 16:00:50 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Sat Jan 14 16:00:50 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 16:00:50 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Jan 14 16:00:50 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sat Jan 14 16:00:50 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Sat Jan 14 16:00:50 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Jan 14 16:00:50 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 16:00:50 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Sat Jan 14 16:00:50 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 16:00:50 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 14 16:00:50 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 16:00:50 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 14 16:00:50 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 14 16:00:50 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 16:00:50 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Sat Jan 14 16:00:50 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0007.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 16:00:50 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Sat Jan 14 16:00:50 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 16:00:50 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Sat Jan 14 16:00:50 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Jan 14 16:00:50 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 16:00:50 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Jan 14 16:00:50 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 16:00:50 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Jan 14 16:00:50 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 16:00:50 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Sat Jan 14 16:00:50 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 16:00:50 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Sat Jan 14 16:00:50 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 16:00:50 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 16:00:50 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Sat Jan 14 16:00:50 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 16:00:50 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sat Jan 14 16:00:50 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0007.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 16:00:50 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Sat Jan 14 16:00:50 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 16:00:50 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sat Jan 14 16:00:50 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0007.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Jan 14 20:00:48 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 20:00:48 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Jan 14 20:00:48 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Jan 14 20:00:48 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 14 20:00:48 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 20:00:48 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 14 20:00:48 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sat Jan 14 20:00:49 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Jan 14 20:00:49 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 20:00:49 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Sat Jan 14 20:00:49 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 20:00:49 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Jan 14 20:00:49 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sat Jan 14 20:00:49 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Sat Jan 14 20:00:49 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Jan 14 20:00:49 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 20:00:49 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Sat Jan 14 20:00:49 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 20:00:49 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 14 20:00:49 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 20:00:49 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 14 20:00:49 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 14 20:00:49 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 20:00:49 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Sat Jan 14 20:00:49 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0008.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 20:00:49 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Sat Jan 14 20:00:49 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 20:00:49 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Sat Jan 14 20:00:49 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Jan 14 20:00:49 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 20:00:49 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Jan 14 20:00:49 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 20:00:49 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Jan 14 20:00:49 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 20:00:49 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Sat Jan 14 20:00:49 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 20:00:49 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Sat Jan 14 20:00:49 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 20:00:49 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 20:00:49 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Sat Jan 14 20:00:49 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 20:00:49 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sat Jan 14 20:00:49 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0008.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 20:00:49 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Sat Jan 14 20:00:49 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 14 20:00:49 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sat Jan 14 20:00:49 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0008.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Jan 15 08:02:15 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 08:02:15 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Jan 15 08:02:15 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Jan 15 08:02:15 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 15 08:02:15 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 08:02:15 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 15 08:02:16 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sun Jan 15 08:02:16 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Jan 15 08:02:16 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 08:02:16 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Sun Jan 15 08:02:16 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 08:02:16 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Jan 15 08:02:16 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sun Jan 15 08:02:16 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Sun Jan 15 08:02:16 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Jan 15 08:02:16 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 08:02:16 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Sun Jan 15 08:02:16 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 08:02:16 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 15 08:02:16 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 08:02:16 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 15 08:02:16 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 15 08:02:16 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 08:02:16 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Sun Jan 15 08:02:16 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0009.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 08:02:16 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Sun Jan 15 08:02:16 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 08:02:16 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Sun Jan 15 08:02:16 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Jan 15 08:02:16 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 08:02:16 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Jan 15 08:02:16 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 08:02:16 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Jan 15 08:02:16 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 08:02:16 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Sun Jan 15 08:02:16 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 08:02:16 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Sun Jan 15 08:02:16 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 08:02:16 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 08:02:16 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Sun Jan 15 08:02:16 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 08:02:16 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sun Jan 15 08:02:16 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0009.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 08:02:16 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Sun Jan 15 08:02:16 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 08:02:16 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sun Jan 15 08:02:16 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0009.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Jan 15 12:00:57 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 12:00:57 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Jan 15 12:00:57 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Jan 15 12:00:57 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 15 12:00:57 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 12:00:57 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 15 12:00:57 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sun Jan 15 12:00:57 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Jan 15 12:00:57 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 12:00:57 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Sun Jan 15 12:00:57 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 12:00:57 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Jan 15 12:00:57 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sun Jan 15 12:00:57 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Sun Jan 15 12:00:57 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Jan 15 12:00:57 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 12:00:57 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Sun Jan 15 12:00:57 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 12:00:57 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 15 12:00:57 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 12:00:57 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 15 12:00:57 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 15 12:00:57 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 12:00:57 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Sun Jan 15 12:00:57 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0010.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 12:00:57 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Sun Jan 15 12:00:58 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 12:00:58 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Sun Jan 15 12:00:58 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Jan 15 12:00:58 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 12:00:58 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Jan 15 12:00:58 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 12:00:58 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Jan 15 12:00:58 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 12:00:58 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Sun Jan 15 12:00:58 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 12:00:58 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Sun Jan 15 12:00:58 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 12:00:58 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 12:00:58 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Sun Jan 15 12:00:58 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 12:00:58 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sun Jan 15 12:00:58 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0010.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 12:00:58 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Sun Jan 15 12:00:58 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 12:00:58 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sun Jan 15 12:00:58 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0010.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Jan 15 16:00:49 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 16:00:49 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Jan 15 16:00:49 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Jan 15 16:00:49 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 15 16:00:49 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 16:00:49 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 15 16:00:49 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sun Jan 15 16:00:49 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Jan 15 16:00:49 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 16:00:49 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Sun Jan 15 16:00:49 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 16:00:49 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Jan 15 16:00:50 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sun Jan 15 16:00:50 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Sun Jan 15 16:00:50 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Jan 15 16:00:50 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 16:00:50 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Sun Jan 15 16:00:50 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 16:00:50 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 15 16:00:50 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 16:00:50 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 15 16:00:50 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 15 16:00:50 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 16:00:50 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Sun Jan 15 16:00:50 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0011.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 16:00:50 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Sun Jan 15 16:00:50 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 16:00:50 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Sun Jan 15 16:00:50 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Jan 15 16:00:50 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 16:00:50 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Jan 15 16:00:50 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 16:00:50 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Jan 15 16:00:50 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 16:00:50 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Sun Jan 15 16:00:50 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 16:00:50 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Sun Jan 15 16:00:50 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 16:00:50 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 16:00:50 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Sun Jan 15 16:00:50 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 16:00:50 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sun Jan 15 16:00:50 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0011.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 16:00:50 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Sun Jan 15 16:00:50 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 16:00:50 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sun Jan 15 16:00:50 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0011.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Jan 15 20:00:49 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 20:00:49 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Jan 15 20:00:49 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Jan 15 20:00:49 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 15 20:00:49 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 20:00:49 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 15 20:00:49 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sun Jan 15 20:00:49 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Jan 15 20:00:49 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 20:00:49 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Sun Jan 15 20:00:49 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 20:00:49 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Jan 15 20:00:49 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sun Jan 15 20:00:49 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Sun Jan 15 20:00:49 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Jan 15 20:00:49 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 20:00:49 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Sun Jan 15 20:00:49 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 20:00:49 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 15 20:00:49 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 20:00:49 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 15 20:00:49 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 15 20:00:49 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 20:00:49 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Sun Jan 15 20:00:49 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0012.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 20:00:49 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Sun Jan 15 20:00:49 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 20:00:49 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Sun Jan 15 20:00:49 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Jan 15 20:00:49 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 20:00:49 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Jan 15 20:00:49 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 20:00:49 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Jan 15 20:00:49 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 20:00:49 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Sun Jan 15 20:00:49 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 20:00:49 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Sun Jan 15 20:00:49 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 20:00:49 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 20:00:49 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Sun Jan 15 20:00:50 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 20:00:50 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sun Jan 15 20:00:50 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0012.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 20:00:50 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Sun Jan 15 20:00:50 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 15 20:00:50 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sun Jan 15 20:00:50 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0012.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Jan 16 08:02:39 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 08:02:39 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Jan 16 08:02:39 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Jan 16 08:02:39 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 16 08:02:39 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 08:02:39 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 16 08:02:39 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Mon Jan 16 08:02:39 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Jan 16 08:02:39 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 08:02:39 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Mon Jan 16 08:02:39 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 08:02:39 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Jan 16 08:02:39 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Mon Jan 16 08:02:39 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Mon Jan 16 08:02:39 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Jan 16 08:02:39 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 08:02:39 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Mon Jan 16 08:02:39 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 08:02:39 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 16 08:02:39 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 08:02:39 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 16 08:02:39 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 16 08:02:39 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 08:02:39 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Mon Jan 16 08:02:40 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0013.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 08:02:40 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Mon Jan 16 08:02:40 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 08:02:40 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Mon Jan 16 08:02:40 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Jan 16 08:02:40 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 08:02:40 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Jan 16 08:02:40 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 08:02:40 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Jan 16 08:02:40 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 08:02:40 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Mon Jan 16 08:02:40 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 08:02:40 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Mon Jan 16 08:02:40 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 08:02:40 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 08:02:40 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Mon Jan 16 08:02:40 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 08:02:40 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Mon Jan 16 08:02:40 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0013.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 08:02:40 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Mon Jan 16 08:02:40 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 08:02:40 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Mon Jan 16 08:02:40 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0013.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Jan 16 12:00:53 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 12:00:53 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Jan 16 12:00:53 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Jan 16 12:00:53 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 16 12:00:53 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 12:00:53 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 16 12:00:53 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Mon Jan 16 12:00:53 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Jan 16 12:00:53 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 12:00:53 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Mon Jan 16 12:00:53 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 12:00:53 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Jan 16 12:00:53 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Mon Jan 16 12:00:54 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Mon Jan 16 12:00:54 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Jan 16 12:00:54 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 12:00:54 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Mon Jan 16 12:00:54 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 12:00:54 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 16 12:00:54 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 12:00:54 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 16 12:00:54 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 16 12:00:54 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 12:00:54 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Mon Jan 16 12:00:54 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0014.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 12:00:54 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Mon Jan 16 12:00:54 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 12:00:54 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Mon Jan 16 12:00:54 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Jan 16 12:00:54 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 12:00:54 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Jan 16 12:00:54 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 12:00:54 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Jan 16 12:00:54 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 12:00:54 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Mon Jan 16 12:00:54 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 12:00:54 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Mon Jan 16 12:00:54 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 12:00:54 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 12:00:54 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Mon Jan 16 12:00:54 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 12:00:54 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Mon Jan 16 12:00:54 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0014.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 12:00:54 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Mon Jan 16 12:00:54 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 12:00:54 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Mon Jan 16 12:00:54 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0014.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Jan 16 16:00:53 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 16:00:53 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Jan 16 16:00:53 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Jan 16 16:00:53 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 16 16:00:53 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 16:00:53 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 16 16:00:53 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Mon Jan 16 16:00:53 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Jan 16 16:00:53 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 16:00:53 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Mon Jan 16 16:00:53 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 16:00:53 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Jan 16 16:00:53 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Mon Jan 16 16:00:53 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Mon Jan 16 16:00:53 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Jan 16 16:00:53 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 16:00:53 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Mon Jan 16 16:00:53 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 16:00:53 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 16 16:00:53 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 16:00:53 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 16 16:00:54 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 16 16:00:54 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 16:00:54 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Mon Jan 16 16:00:54 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0015.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 16:00:54 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Mon Jan 16 16:00:54 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 16:00:54 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Mon Jan 16 16:00:54 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Jan 16 16:00:54 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 16:00:54 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Jan 16 16:00:54 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 16:00:54 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Jan 16 16:00:54 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 16:00:54 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Mon Jan 16 16:00:54 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 16:00:54 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Mon Jan 16 16:00:54 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 16:00:54 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 16:00:54 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Mon Jan 16 16:00:54 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 16:00:54 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Mon Jan 16 16:00:54 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0015.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 16:00:54 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Mon Jan 16 16:00:54 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 16:00:54 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Mon Jan 16 16:00:54 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0015.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0016.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0016.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Mon Jan 16 20:00:51 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0016.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Jan 17 08:02:42 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 08:02:42 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Jan 17 08:02:42 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Jan 17 08:02:42 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 17 08:02:42 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 08:02:42 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 17 08:02:42 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Tue Jan 17 08:02:42 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Jan 17 08:02:42 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 08:02:42 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Tue Jan 17 08:02:42 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 08:02:42 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Jan 17 08:02:42 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Tue Jan 17 08:02:42 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Tue Jan 17 08:02:42 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Jan 17 08:02:42 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 08:02:42 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Tue Jan 17 08:02:42 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 08:02:42 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 17 08:02:42 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 08:02:42 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 17 08:02:42 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 17 08:02:42 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 08:02:42 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Tue Jan 17 08:02:42 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0017.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 08:02:42 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Tue Jan 17 08:02:43 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 08:02:43 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Tue Jan 17 08:02:43 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Jan 17 08:02:43 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 08:02:43 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Jan 17 08:02:43 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 08:02:43 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Jan 17 08:02:43 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 08:02:43 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Tue Jan 17 08:02:43 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 08:02:43 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Tue Jan 17 08:02:43 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 08:02:43 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 08:02:43 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Tue Jan 17 08:02:43 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 08:02:43 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Tue Jan 17 08:02:43 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0017.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 08:02:43 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Tue Jan 17 08:02:43 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 08:02:43 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Tue Jan 17 08:02:43 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0017.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Jan 17 12:01:10 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 12:01:11 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Jan 17 12:01:11 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Jan 17 12:01:11 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 17 12:01:11 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 12:01:11 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 17 12:01:11 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Tue Jan 17 12:01:11 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Jan 17 12:01:11 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 12:01:11 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Tue Jan 17 12:01:11 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 12:01:11 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Jan 17 12:01:11 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Tue Jan 17 12:01:11 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Tue Jan 17 12:01:11 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Jan 17 12:01:11 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 12:01:11 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Tue Jan 17 12:01:11 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 12:01:11 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 17 12:01:11 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 12:01:11 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 17 12:01:11 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 17 12:01:11 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 12:01:11 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Tue Jan 17 12:01:11 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0018.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 12:01:11 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Tue Jan 17 12:01:11 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 12:01:11 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Tue Jan 17 12:01:11 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Jan 17 12:01:11 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 12:01:11 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Jan 17 12:01:11 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 12:01:11 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Jan 17 12:01:11 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 12:01:11 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Tue Jan 17 12:01:11 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 12:01:12 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Tue Jan 17 12:01:12 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 12:01:12 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 12:01:12 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Tue Jan 17 12:01:12 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 12:01:12 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Tue Jan 17 12:01:12 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0018.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 12:01:12 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Tue Jan 17 12:01:12 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 12:01:12 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Tue Jan 17 12:01:12 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0018.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Jan 17 16:00:55 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 16:00:56 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Jan 17 16:00:56 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Jan 17 16:00:56 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 17 16:00:56 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 16:00:56 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 17 16:00:56 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Tue Jan 17 16:00:56 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Jan 17 16:00:56 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 16:00:56 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Tue Jan 17 16:00:56 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 16:00:56 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Jan 17 16:00:56 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Tue Jan 17 16:00:56 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Tue Jan 17 16:00:56 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Jan 17 16:00:56 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 16:00:56 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Tue Jan 17 16:00:56 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 16:00:56 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 17 16:00:56 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 16:00:56 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 17 16:00:56 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 17 16:00:56 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 16:00:56 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Tue Jan 17 16:00:56 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0019.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 16:00:56 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Tue Jan 17 16:00:56 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 16:00:56 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Tue Jan 17 16:00:56 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Jan 17 16:00:56 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 16:00:56 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Jan 17 16:00:56 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 16:00:57 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Jan 17 16:00:57 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 16:00:57 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Tue Jan 17 16:00:57 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 16:00:58 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Tue Jan 17 16:00:58 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 16:00:58 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 16:00:58 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Tue Jan 17 16:00:58 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 16:00:58 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Tue Jan 17 16:00:58 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0019.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 16:00:58 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Tue Jan 17 16:00:58 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 16:00:58 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Tue Jan 17 16:00:58 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0019.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Jan 17 20:00:56 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0020.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0020.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Tue Jan 17 20:00:57 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0020.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Jan 18 08:04:27 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 08:04:27 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Jan 18 08:04:27 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Jan 18 08:04:27 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Jan 18 08:04:27 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 08:04:27 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Jan 18 08:04:27 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Wed Jan 18 08:04:27 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Jan 18 08:04:27 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 08:04:27 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Wed Jan 18 08:04:27 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 08:04:28 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Jan 18 08:04:28 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Wed Jan 18 08:04:28 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Wed Jan 18 08:04:28 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Jan 18 08:04:28 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 08:04:28 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Wed Jan 18 08:04:28 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 08:04:28 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Jan 18 08:04:28 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 08:04:28 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Jan 18 08:04:28 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Jan 18 08:04:28 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 08:04:28 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Wed Jan 18 08:04:28 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0021.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 08:04:28 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Wed Jan 18 08:04:28 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 08:04:28 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Wed Jan 18 08:04:28 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Jan 18 08:04:28 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 08:04:28 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Jan 18 08:04:28 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 08:04:29 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Jan 18 08:04:29 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 08:04:29 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Wed Jan 18 08:04:29 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 08:04:29 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Wed Jan 18 08:04:29 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 08:04:29 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 08:04:29 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Wed Jan 18 08:04:29 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 08:04:29 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Wed Jan 18 08:04:29 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0021.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 08:04:29 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Wed Jan 18 08:04:29 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 08:04:29 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Wed Jan 18 08:04:29 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0021.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Jan 18 12:01:11 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 12:01:11 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Jan 18 12:01:11 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Jan 18 12:01:11 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Jan 18 12:01:11 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 12:01:11 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Jan 18 12:01:11 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Wed Jan 18 12:01:11 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Jan 18 12:01:11 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 12:01:11 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Wed Jan 18 12:01:11 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 12:01:11 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Jan 18 12:01:11 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Wed Jan 18 12:01:11 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Wed Jan 18 12:01:11 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Jan 18 12:01:11 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 12:01:11 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Wed Jan 18 12:01:11 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 12:01:11 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Jan 18 12:01:11 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 12:01:11 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Jan 18 12:01:11 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Jan 18 12:01:11 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 12:01:11 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Wed Jan 18 12:01:11 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0022.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 12:01:11 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Wed Jan 18 12:01:11 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 12:01:11 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Wed Jan 18 12:01:11 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Jan 18 12:01:12 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 12:01:12 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Jan 18 12:01:12 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 12:01:12 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Jan 18 12:01:12 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 12:01:12 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Wed Jan 18 12:01:12 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 12:01:12 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Wed Jan 18 12:01:12 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 12:01:12 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 12:01:12 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Wed Jan 18 12:01:12 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 12:01:12 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Wed Jan 18 12:01:12 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0022.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 12:01:12 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Wed Jan 18 12:01:12 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 12:01:12 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Wed Jan 18 12:01:12 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0022.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Jan 18 16:01:39 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 16:01:39 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Jan 18 16:01:39 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Jan 18 16:01:39 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Jan 18 16:01:39 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 16:01:39 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Jan 18 16:01:39 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Wed Jan 18 16:01:39 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Jan 18 16:01:39 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 16:01:39 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Wed Jan 18 16:01:39 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 16:01:39 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Jan 18 16:01:39 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Wed Jan 18 16:01:39 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Wed Jan 18 16:01:39 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Jan 18 16:01:39 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 16:01:39 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Wed Jan 18 16:01:39 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 16:01:39 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Jan 18 16:01:40 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 16:01:40 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Jan 18 16:01:40 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Jan 18 16:01:40 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 16:01:40 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Wed Jan 18 16:01:40 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0023.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 16:01:40 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Wed Jan 18 16:01:40 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 16:01:40 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Wed Jan 18 16:01:40 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Jan 18 16:01:40 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 16:01:40 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Jan 18 16:01:40 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 16:01:40 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Jan 18 16:01:40 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 16:01:40 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Wed Jan 18 16:01:40 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 16:01:40 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Wed Jan 18 16:01:40 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 16:01:40 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 16:01:40 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Wed Jan 18 16:01:40 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 16:01:40 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Wed Jan 18 16:01:40 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0023.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 16:01:40 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Wed Jan 18 16:01:41 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 16:01:41 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Wed Jan 18 16:01:41 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0023.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Jan 18 20:01:02 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 20:01:02 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Jan 18 20:01:02 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Jan 18 20:01:02 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Jan 18 20:01:02 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 20:01:02 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Jan 18 20:01:02 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Wed Jan 18 20:01:02 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Jan 18 20:01:02 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 20:01:02 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Wed Jan 18 20:01:02 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 20:01:02 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Jan 18 20:01:02 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Wed Jan 18 20:01:02 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Wed Jan 18 20:01:02 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Jan 18 20:01:02 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 20:01:02 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Wed Jan 18 20:01:02 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 20:01:02 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Jan 18 20:01:02 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 20:01:02 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Jan 18 20:01:02 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Jan 18 20:01:02 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 20:01:02 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Wed Jan 18 20:01:02 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0024.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 20:01:02 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Wed Jan 18 20:01:02 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 20:01:02 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Wed Jan 18 20:01:02 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Jan 18 20:01:02 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 20:01:02 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Jan 18 20:01:03 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 20:01:03 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Jan 18 20:01:03 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 20:01:03 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Wed Jan 18 20:01:03 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 20:01:03 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Wed Jan 18 20:01:03 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 20:01:03 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 20:01:03 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Wed Jan 18 20:01:03 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 20:01:03 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Wed Jan 18 20:01:03 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0024.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 20:01:03 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Wed Jan 18 20:01:03 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 18 20:01:03 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Wed Jan 18 20:01:03 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0024.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Jan 19 08:04:48 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 08:04:50 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Jan 19 08:04:50 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Jan 19 08:04:50 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Jan 19 08:04:50 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 08:04:50 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Jan 19 08:04:50 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Thu Jan 19 08:04:50 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Jan 19 08:04:50 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 08:04:50 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Thu Jan 19 08:04:50 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 08:04:50 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Jan 19 08:04:50 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Thu Jan 19 08:04:50 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Thu Jan 19 08:04:50 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Jan 19 08:04:50 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 08:04:50 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Thu Jan 19 08:04:50 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 08:04:50 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Jan 19 08:04:50 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 08:04:50 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Jan 19 08:04:50 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Jan 19 08:04:50 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 08:04:50 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Thu Jan 19 08:04:51 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0025.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 08:04:51 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Thu Jan 19 08:04:51 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 08:04:51 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Thu Jan 19 08:04:51 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Jan 19 08:04:51 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 08:04:51 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Jan 19 08:04:51 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 08:04:51 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Jan 19 08:04:51 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 08:04:51 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Thu Jan 19 08:04:51 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 08:04:51 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Thu Jan 19 08:04:51 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 08:04:51 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 08:04:51 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Thu Jan 19 08:04:51 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 08:04:51 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Thu Jan 19 08:04:51 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0025.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 08:04:51 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Thu Jan 19 08:04:51 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 08:04:51 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Thu Jan 19 08:04:51 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0025.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Jan 19 12:01:09 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 12:01:09 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Jan 19 12:01:09 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Jan 19 12:01:09 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Jan 19 12:01:09 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 12:01:09 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Jan 19 12:01:09 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Thu Jan 19 12:01:09 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Jan 19 12:01:09 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 12:01:09 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Thu Jan 19 12:01:09 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 12:01:09 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Jan 19 12:01:09 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Thu Jan 19 12:01:09 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Thu Jan 19 12:01:09 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Jan 19 12:01:09 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 12:01:09 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Thu Jan 19 12:01:09 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 12:01:09 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Jan 19 12:01:09 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 12:01:09 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Jan 19 12:01:09 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Jan 19 12:01:09 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 12:01:09 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Thu Jan 19 12:01:09 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0026.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 12:01:09 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Thu Jan 19 12:01:09 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 12:01:09 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Thu Jan 19 12:01:09 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Jan 19 12:01:09 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 12:01:09 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Jan 19 12:01:09 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 12:01:09 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Jan 19 12:01:09 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 12:01:09 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Thu Jan 19 12:01:09 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 12:01:09 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Thu Jan 19 12:01:10 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 12:01:10 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 12:01:10 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Thu Jan 19 12:01:10 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 12:01:10 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Thu Jan 19 12:01:10 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0026.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 12:01:10 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Thu Jan 19 12:01:10 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 12:01:10 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Thu Jan 19 12:01:10 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0026.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Jan 19 16:03:23 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 16:03:23 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Jan 19 16:03:23 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Jan 19 16:03:23 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Jan 19 16:03:23 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 16:03:24 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Jan 19 16:03:24 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Thu Jan 19 16:03:24 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Jan 19 16:03:24 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 16:03:24 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Thu Jan 19 16:03:24 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 16:03:24 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Jan 19 16:03:24 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Thu Jan 19 16:03:24 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Thu Jan 19 16:03:24 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Jan 19 16:03:25 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 16:03:25 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Thu Jan 19 16:03:25 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 16:03:25 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Jan 19 16:03:25 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 16:03:25 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Jan 19 16:03:25 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Jan 19 16:03:25 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 16:03:25 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Thu Jan 19 16:03:25 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0027.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 16:03:26 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Thu Jan 19 16:03:26 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 16:03:26 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Thu Jan 19 16:03:26 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Jan 19 16:03:26 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 16:03:26 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Jan 19 16:03:26 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 16:03:26 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Jan 19 16:03:26 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 16:03:26 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Thu Jan 19 16:03:27 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 16:03:27 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Thu Jan 19 16:03:27 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 16:03:27 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 16:03:27 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Thu Jan 19 16:03:27 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 16:03:27 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Thu Jan 19 16:03:27 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0027.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 16:03:27 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Thu Jan 19 16:03:27 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 16:03:28 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Thu Jan 19 16:03:28 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0027.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Jan 19 20:00:54 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 20:00:54 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Jan 19 20:00:54 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Jan 19 20:00:54 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Jan 19 20:00:54 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 20:00:54 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Jan 19 20:00:54 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Thu Jan 19 20:00:54 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Jan 19 20:00:54 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 20:00:54 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Thu Jan 19 20:00:54 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 20:00:54 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Jan 19 20:00:54 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Thu Jan 19 20:00:54 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Thu Jan 19 20:00:54 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Jan 19 20:00:54 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 20:00:54 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Thu Jan 19 20:00:54 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 20:00:54 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Jan 19 20:00:54 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 20:00:54 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Jan 19 20:00:54 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Jan 19 20:00:54 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 20:00:54 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Thu Jan 19 20:00:54 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0028.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 20:00:54 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Thu Jan 19 20:00:54 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 20:00:54 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Thu Jan 19 20:00:54 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Jan 19 20:00:54 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 20:00:54 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Jan 19 20:00:54 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 20:00:54 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Jan 19 20:00:54 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 20:00:55 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Thu Jan 19 20:00:55 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 20:00:55 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Thu Jan 19 20:00:55 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 20:00:55 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 20:00:55 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Thu Jan 19 20:00:55 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 20:00:55 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Thu Jan 19 20:00:55 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0028.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 20:00:55 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Thu Jan 19 20:00:55 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 19 20:00:55 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Thu Jan 19 20:00:55 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0028.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Jan 20 08:07:42 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 08:07:44 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Jan 20 08:07:44 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Jan 20 08:07:44 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 20 08:07:44 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 08:07:44 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 20 08:07:44 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Fri Jan 20 08:07:44 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Jan 20 08:07:44 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 08:07:44 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Fri Jan 20 08:07:44 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 08:07:44 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Jan 20 08:07:44 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Fri Jan 20 08:07:45 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Fri Jan 20 08:07:45 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Jan 20 08:07:45 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 08:07:45 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Fri Jan 20 08:07:45 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 08:07:45 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 20 08:07:45 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 08:07:45 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 20 08:07:45 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 20 08:07:46 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 08:07:46 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Fri Jan 20 08:07:48 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0029.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 08:07:48 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Fri Jan 20 08:07:49 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 08:07:49 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Fri Jan 20 08:07:49 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Jan 20 08:07:49 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 08:07:49 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Jan 20 08:07:49 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 08:07:49 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Jan 20 08:07:49 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 08:07:50 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Fri Jan 20 08:07:50 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 08:07:50 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Fri Jan 20 08:07:50 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 08:07:50 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 08:07:50 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Fri Jan 20 08:07:50 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 08:07:50 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Fri Jan 20 08:07:50 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0029.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 08:07:50 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Fri Jan 20 08:07:50 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 08:07:50 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Fri Jan 20 08:07:50 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0029.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Jan 20 12:02:19 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 12:02:19 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Jan 20 12:02:19 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Jan 20 12:02:19 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 20 12:02:19 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 12:02:19 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 20 12:02:19 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Fri Jan 20 12:02:19 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Jan 20 12:02:19 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 12:02:19 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Fri Jan 20 12:02:19 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 12:02:19 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Jan 20 12:02:19 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Fri Jan 20 12:02:19 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Fri Jan 20 12:02:19 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Jan 20 12:02:20 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 12:02:20 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Fri Jan 20 12:02:20 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 12:02:20 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 20 12:02:20 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 12:02:20 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 20 12:02:20 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 20 12:02:20 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 12:02:20 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Fri Jan 20 12:02:20 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0030.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 12:02:20 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Fri Jan 20 12:02:20 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 12:02:20 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Fri Jan 20 12:02:20 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Jan 20 12:02:20 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 12:02:20 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Jan 20 12:02:20 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 12:02:21 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Jan 20 12:02:21 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 12:02:21 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Fri Jan 20 12:02:21 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 12:02:21 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Fri Jan 20 12:02:21 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 12:02:21 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 12:02:21 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Fri Jan 20 12:02:21 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 12:02:21 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Fri Jan 20 12:02:21 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0030.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 12:02:21 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Fri Jan 20 12:02:21 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 12:02:21 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Fri Jan 20 12:02:21 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0030.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Jan 20 16:00:58 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 16:00:58 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Jan 20 16:00:58 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Jan 20 16:00:58 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 20 16:00:58 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 16:00:58 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 20 16:00:58 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Fri Jan 20 16:00:58 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Jan 20 16:00:58 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 16:00:58 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Fri Jan 20 16:00:58 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 16:00:58 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Jan 20 16:00:58 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Fri Jan 20 16:00:58 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Fri Jan 20 16:00:58 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Jan 20 16:00:58 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 16:00:58 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Fri Jan 20 16:00:58 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 16:00:59 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 20 16:00:59 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 16:00:59 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 20 16:00:59 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 20 16:00:59 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 16:00:59 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Fri Jan 20 16:00:59 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0031.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 16:00:59 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Fri Jan 20 16:00:59 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 16:00:59 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Fri Jan 20 16:00:59 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Jan 20 16:00:59 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 16:00:59 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Jan 20 16:00:59 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 16:00:59 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Jan 20 16:00:59 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 16:00:59 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Fri Jan 20 16:00:59 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 16:00:59 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Fri Jan 20 16:00:59 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 16:00:59 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 16:00:59 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Fri Jan 20 16:00:59 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 16:00:59 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Fri Jan 20 16:00:59 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0031.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 16:00:59 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Fri Jan 20 16:00:59 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 16:00:59 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Fri Jan 20 16:00:59 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0031.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Jan 20 20:00:55 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 20:00:55 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Jan 20 20:00:55 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Jan 20 20:00:55 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 20 20:00:55 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 20:00:55 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 20 20:00:55 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Fri Jan 20 20:00:56 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Jan 20 20:00:56 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 20:00:56 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Fri Jan 20 20:00:56 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 20:00:56 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Jan 20 20:00:56 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Fri Jan 20 20:00:56 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Fri Jan 20 20:00:56 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Jan 20 20:00:56 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 20:00:56 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Fri Jan 20 20:00:56 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 20:00:56 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 20 20:00:56 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 20:00:56 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 20 20:00:56 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 20 20:00:56 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 20:00:56 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Fri Jan 20 20:00:56 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0032.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 20:00:56 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Fri Jan 20 20:00:56 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 20:00:56 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Fri Jan 20 20:00:56 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Jan 20 20:00:56 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 20:00:56 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Jan 20 20:00:56 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 20:00:56 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Jan 20 20:00:56 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 20:00:56 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Fri Jan 20 20:00:56 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 20:00:56 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Fri Jan 20 20:00:56 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 20:00:56 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 20:00:56 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Fri Jan 20 20:00:56 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 20:00:56 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Fri Jan 20 20:00:56 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0032.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 20:00:56 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Fri Jan 20 20:00:56 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 20 20:00:56 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Fri Jan 20 20:00:56 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0032.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Jan 21 08:04:06 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 08:04:06 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Jan 21 08:04:06 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Jan 21 08:04:06 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 21 08:04:06 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 08:04:06 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 21 08:04:06 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sat Jan 21 08:04:06 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Jan 21 08:04:06 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 08:04:06 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Sat Jan 21 08:04:06 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 08:04:06 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Jan 21 08:04:06 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sat Jan 21 08:04:06 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Sat Jan 21 08:04:06 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Jan 21 08:04:06 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 08:04:06 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Sat Jan 21 08:04:06 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 08:04:06 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 21 08:04:06 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 08:04:06 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 21 08:04:06 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 21 08:04:06 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 08:04:06 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Sat Jan 21 08:04:06 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0033.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 08:04:06 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Sat Jan 21 08:04:07 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 08:04:07 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Sat Jan 21 08:04:07 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Jan 21 08:04:07 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 08:04:07 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Jan 21 08:04:07 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 08:04:07 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Jan 21 08:04:07 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 08:04:07 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Sat Jan 21 08:04:07 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 08:04:07 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Sat Jan 21 08:04:07 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 08:04:07 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 08:04:07 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Sat Jan 21 08:04:07 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 08:04:07 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sat Jan 21 08:04:07 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0033.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 08:04:07 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Sat Jan 21 08:04:07 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 08:04:07 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sat Jan 21 08:04:07 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0033.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Jan 21 12:01:09 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 12:01:09 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Jan 21 12:01:09 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Jan 21 12:01:09 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 21 12:01:09 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 12:01:09 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 21 12:01:09 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sat Jan 21 12:01:09 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Jan 21 12:01:09 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 12:01:09 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Sat Jan 21 12:01:09 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 12:01:09 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Jan 21 12:01:09 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sat Jan 21 12:01:09 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Sat Jan 21 12:01:09 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Jan 21 12:01:09 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 12:01:09 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Sat Jan 21 12:01:09 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 12:01:09 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 21 12:01:09 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 12:01:09 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 21 12:01:09 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 21 12:01:09 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 12:01:09 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Sat Jan 21 12:01:09 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0034.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 12:01:09 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Sat Jan 21 12:01:09 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 12:01:09 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Sat Jan 21 12:01:09 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Jan 21 12:01:09 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 12:01:09 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Jan 21 12:01:09 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 12:01:09 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Jan 21 12:01:09 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 12:01:09 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Sat Jan 21 12:01:09 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 12:01:09 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Sat Jan 21 12:01:10 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 12:01:10 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 12:01:10 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Sat Jan 21 12:01:10 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 12:01:10 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sat Jan 21 12:01:10 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0034.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 12:01:10 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Sat Jan 21 12:01:10 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 12:01:10 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sat Jan 21 12:01:10 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0034.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Jan 21 16:00:57 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 16:00:57 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Jan 21 16:00:57 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Jan 21 16:00:57 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 21 16:00:57 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 16:00:57 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 21 16:00:57 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sat Jan 21 16:00:57 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Jan 21 16:00:57 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 16:00:57 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Sat Jan 21 16:00:57 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 16:00:57 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Jan 21 16:00:57 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sat Jan 21 16:00:57 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Sat Jan 21 16:00:57 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Jan 21 16:00:57 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 16:00:57 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Sat Jan 21 16:00:57 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 16:00:57 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 21 16:00:57 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 16:00:57 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 21 16:00:57 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 21 16:00:57 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 16:00:57 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Sat Jan 21 16:00:57 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0035.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 16:00:57 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Sat Jan 21 16:00:57 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 16:00:57 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Sat Jan 21 16:00:57 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Jan 21 16:00:57 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 16:00:57 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Jan 21 16:00:57 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 16:00:57 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Jan 21 16:00:57 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 16:00:57 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Sat Jan 21 16:00:57 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 16:00:57 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Sat Jan 21 16:00:57 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 16:00:57 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 16:00:57 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Sat Jan 21 16:00:57 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 16:00:57 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sat Jan 21 16:00:57 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0035.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 16:00:57 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Sat Jan 21 16:00:58 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 16:00:58 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sat Jan 21 16:00:58 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0035.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Jan 21 20:00:55 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 20:00:55 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Jan 21 20:00:55 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Jan 21 20:00:55 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 21 20:00:55 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 20:00:55 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 21 20:00:55 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sat Jan 21 20:00:55 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Jan 21 20:00:55 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 20:00:55 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Sat Jan 21 20:00:55 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 20:00:55 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Jan 21 20:00:55 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sat Jan 21 20:00:55 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Sat Jan 21 20:00:55 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Jan 21 20:00:55 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 20:00:55 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Sat Jan 21 20:00:55 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 20:00:56 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 21 20:00:56 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 20:00:56 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 21 20:00:56 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 21 20:00:56 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 20:00:56 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Sat Jan 21 20:00:56 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0036.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 20:00:56 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Sat Jan 21 20:00:56 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 20:00:56 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Sat Jan 21 20:00:56 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Jan 21 20:00:56 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 20:00:56 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Jan 21 20:00:56 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 20:00:56 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Jan 21 20:00:56 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 20:00:56 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Sat Jan 21 20:00:56 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 20:00:56 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Sat Jan 21 20:00:56 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 20:00:56 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 20:00:56 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Sat Jan 21 20:00:56 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 20:00:56 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sat Jan 21 20:00:56 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0036.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 20:00:56 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Sat Jan 21 20:00:56 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 21 20:00:56 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sat Jan 21 20:00:56 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0036.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Jan 22 08:02:56 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 08:02:56 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Jan 22 08:02:56 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Jan 22 08:02:57 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 22 08:02:57 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 08:02:57 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 22 08:02:57 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sun Jan 22 08:02:57 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Jan 22 08:02:57 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 08:02:57 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Sun Jan 22 08:02:57 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 08:02:57 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Jan 22 08:02:57 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sun Jan 22 08:02:57 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Sun Jan 22 08:02:57 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Jan 22 08:02:57 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 08:02:57 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Sun Jan 22 08:02:57 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 08:02:57 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 22 08:02:57 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 08:02:57 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 22 08:02:57 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 22 08:02:57 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 08:02:57 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Sun Jan 22 08:02:57 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0037.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 08:02:57 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Sun Jan 22 08:02:57 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 08:02:57 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Sun Jan 22 08:02:57 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Jan 22 08:02:57 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 08:02:57 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Jan 22 08:02:57 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 08:02:57 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Jan 22 08:02:57 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 08:02:57 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Sun Jan 22 08:02:57 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 08:02:57 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Sun Jan 22 08:02:58 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 08:02:58 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 08:02:58 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Sun Jan 22 08:02:58 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 08:02:58 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sun Jan 22 08:02:58 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0037.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 08:02:58 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Sun Jan 22 08:02:58 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 08:02:58 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sun Jan 22 08:02:58 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0037.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Jan 22 12:00:58 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 12:00:58 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Jan 22 12:00:58 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Jan 22 12:00:58 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 22 12:00:58 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 12:00:58 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 22 12:00:58 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sun Jan 22 12:00:58 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Jan 22 12:00:58 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 12:00:58 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Sun Jan 22 12:00:58 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 12:00:58 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Jan 22 12:00:58 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sun Jan 22 12:00:58 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Sun Jan 22 12:00:58 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Jan 22 12:00:58 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 12:00:58 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Sun Jan 22 12:00:58 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 12:00:58 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 22 12:00:58 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 12:00:59 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 22 12:00:59 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 22 12:00:59 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 12:00:59 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Sun Jan 22 12:00:59 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0038.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 12:00:59 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Sun Jan 22 12:00:59 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 12:00:59 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Sun Jan 22 12:00:59 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Jan 22 12:00:59 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 12:00:59 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Jan 22 12:00:59 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 12:00:59 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Jan 22 12:00:59 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 12:00:59 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Sun Jan 22 12:00:59 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 12:00:59 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Sun Jan 22 12:00:59 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 12:00:59 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 12:00:59 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Sun Jan 22 12:00:59 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 12:00:59 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sun Jan 22 12:00:59 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0038.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 12:00:59 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Sun Jan 22 12:00:59 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 12:00:59 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sun Jan 22 12:00:59 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0038.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Jan 22 16:01:30 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 16:01:31 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Jan 22 16:01:31 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Jan 22 16:01:31 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 22 16:01:31 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 16:01:31 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 22 16:01:31 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sun Jan 22 16:01:31 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Jan 22 16:01:31 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 16:01:31 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Sun Jan 22 16:01:31 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 16:01:31 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Jan 22 16:01:31 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sun Jan 22 16:01:31 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Sun Jan 22 16:01:31 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Jan 22 16:01:31 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 16:01:31 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Sun Jan 22 16:01:31 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 16:01:31 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 22 16:01:31 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 16:01:31 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 22 16:01:31 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 22 16:01:31 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 16:01:31 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Sun Jan 22 16:01:31 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0039.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 16:01:31 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Sun Jan 22 16:01:32 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 16:01:32 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Sun Jan 22 16:01:32 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Jan 22 16:01:32 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 16:01:32 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Jan 22 16:01:32 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 16:01:32 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Jan 22 16:01:32 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 16:01:32 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Sun Jan 22 16:01:32 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 16:01:32 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Sun Jan 22 16:01:32 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 16:01:32 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 16:01:32 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Sun Jan 22 16:01:32 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 16:01:32 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sun Jan 22 16:01:32 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0039.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 16:01:32 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Sun Jan 22 16:01:32 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 16:01:32 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sun Jan 22 16:01:32 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0039.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Jan 22 20:01:25 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 20:01:25 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Jan 22 20:01:25 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Jan 22 20:01:25 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 22 20:01:25 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 20:01:25 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 22 20:01:25 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sun Jan 22 20:01:26 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Jan 22 20:01:26 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 20:01:26 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Sun Jan 22 20:01:26 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 20:01:26 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Jan 22 20:01:26 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sun Jan 22 20:01:26 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Sun Jan 22 20:01:26 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Jan 22 20:01:26 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 20:01:26 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Sun Jan 22 20:01:26 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 20:01:26 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 22 20:01:26 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 20:01:26 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 22 20:01:26 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 22 20:01:26 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 20:01:26 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Sun Jan 22 20:01:26 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0040.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 20:01:26 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Sun Jan 22 20:01:26 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 20:01:26 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Sun Jan 22 20:01:26 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Jan 22 20:01:26 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 20:01:26 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Jan 22 20:01:26 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 20:01:27 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Jan 22 20:01:27 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 20:01:27 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Sun Jan 22 20:01:27 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 20:01:27 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Sun Jan 22 20:01:27 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 20:01:27 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 20:01:27 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Sun Jan 22 20:01:27 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 20:01:27 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sun Jan 22 20:01:27 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0040.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 20:01:27 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Sun Jan 22 20:01:27 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 22 20:01:27 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sun Jan 22 20:01:27 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0040.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Jan 23 08:02:53 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 08:02:53 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Jan 23 08:02:53 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Jan 23 08:02:53 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 23 08:02:53 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 08:02:54 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 23 08:02:54 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Mon Jan 23 08:02:54 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Jan 23 08:02:54 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 08:02:54 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Mon Jan 23 08:02:54 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 08:02:54 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Jan 23 08:02:54 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Mon Jan 23 08:02:54 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Mon Jan 23 08:02:54 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Jan 23 08:02:54 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 08:02:54 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Mon Jan 23 08:02:54 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 08:02:54 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 23 08:02:54 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 08:02:54 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 23 08:02:54 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 23 08:02:54 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 08:02:54 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Mon Jan 23 08:02:54 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0041.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 08:02:54 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Mon Jan 23 08:02:54 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 08:02:54 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Mon Jan 23 08:02:54 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Jan 23 08:02:54 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 08:02:54 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Jan 23 08:02:54 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 08:02:54 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Jan 23 08:02:54 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 08:02:54 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Mon Jan 23 08:02:54 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 08:02:54 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Mon Jan 23 08:02:54 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 08:02:54 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 08:02:55 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Mon Jan 23 08:02:55 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 08:02:55 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Mon Jan 23 08:02:55 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0041.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 08:02:55 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Mon Jan 23 08:02:55 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 08:02:55 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Mon Jan 23 08:02:55 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0041.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Jan 23 12:01:03 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 12:01:04 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Jan 23 12:01:04 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Jan 23 12:01:04 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 23 12:01:04 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 12:01:04 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 23 12:01:04 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Mon Jan 23 12:01:04 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Jan 23 12:01:04 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 12:01:04 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Mon Jan 23 12:01:04 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 12:01:04 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Jan 23 12:01:04 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Mon Jan 23 12:01:04 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Mon Jan 23 12:01:04 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Jan 23 12:01:04 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 12:01:04 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Mon Jan 23 12:01:04 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 12:01:04 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 23 12:01:04 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 12:01:04 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 23 12:01:04 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 23 12:01:04 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 12:01:05 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Mon Jan 23 12:01:05 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0042.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 12:01:05 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Mon Jan 23 12:01:05 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 12:01:05 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Mon Jan 23 12:01:05 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Jan 23 12:01:05 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 12:01:05 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Jan 23 12:01:05 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 12:01:05 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Jan 23 12:01:05 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 12:01:05 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Mon Jan 23 12:01:05 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 12:01:05 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Mon Jan 23 12:01:05 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 12:01:05 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 12:01:05 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Mon Jan 23 12:01:05 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 12:01:05 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Mon Jan 23 12:01:05 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0042.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 12:01:05 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Mon Jan 23 12:01:05 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 12:01:05 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Mon Jan 23 12:01:05 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0042.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Jan 23 16:02:02 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 16:02:02 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Jan 23 16:02:02 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Jan 23 16:02:02 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 23 16:02:02 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 16:02:02 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 23 16:02:02 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Mon Jan 23 16:02:03 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Jan 23 16:02:03 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 16:02:03 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Mon Jan 23 16:02:03 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 16:02:03 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Jan 23 16:02:03 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Mon Jan 23 16:02:03 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Mon Jan 23 16:02:03 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Jan 23 16:02:03 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 16:02:03 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Mon Jan 23 16:02:03 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 16:02:03 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 23 16:02:03 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 16:02:03 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 23 16:02:03 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 23 16:02:03 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 16:02:03 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Mon Jan 23 16:02:04 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0043.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 16:02:04 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Mon Jan 23 16:02:04 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 16:02:04 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Mon Jan 23 16:02:04 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Jan 23 16:02:04 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 16:02:04 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Jan 23 16:02:04 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 16:02:04 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Jan 23 16:02:04 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 16:02:04 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Mon Jan 23 16:02:04 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 16:02:04 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Mon Jan 23 16:02:04 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 16:02:04 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 16:02:04 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Mon Jan 23 16:02:04 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 16:02:05 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Mon Jan 23 16:02:05 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0043.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 16:02:05 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Mon Jan 23 16:02:05 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 16:02:05 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Mon Jan 23 16:02:05 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0043.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Jan 23 20:00:57 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 20:00:57 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Jan 23 20:00:57 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Jan 23 20:00:57 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 23 20:00:57 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 20:00:57 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 23 20:00:57 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Mon Jan 23 20:00:57 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Jan 23 20:00:57 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 20:00:58 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Mon Jan 23 20:00:58 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 20:00:58 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Jan 23 20:00:58 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Mon Jan 23 20:00:58 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Mon Jan 23 20:00:58 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Jan 23 20:00:58 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 20:00:58 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Mon Jan 23 20:00:58 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 20:00:58 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 23 20:00:58 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 20:00:58 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 23 20:00:58 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 23 20:00:58 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 20:00:58 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Mon Jan 23 20:00:58 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0044.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 20:00:58 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Mon Jan 23 20:00:58 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 20:00:58 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Mon Jan 23 20:00:58 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Jan 23 20:00:58 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 20:00:58 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Jan 23 20:00:58 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 20:00:58 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Jan 23 20:00:58 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 20:00:58 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Mon Jan 23 20:00:58 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 20:00:58 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Mon Jan 23 20:00:58 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 20:00:58 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 20:00:58 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Mon Jan 23 20:00:58 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 20:00:58 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Mon Jan 23 20:00:58 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0044.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 20:00:58 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Mon Jan 23 20:00:58 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 23 20:00:58 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Mon Jan 23 20:00:58 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0044.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Jan 24 08:03:23 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 08:03:23 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Jan 24 08:03:23 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Jan 24 08:03:23 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 24 08:03:23 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 08:03:23 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 24 08:03:23 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Tue Jan 24 08:03:23 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Jan 24 08:03:23 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 08:03:23 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Tue Jan 24 08:03:23 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 08:03:23 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Jan 24 08:03:23 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Tue Jan 24 08:03:23 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Tue Jan 24 08:03:23 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Jan 24 08:03:23 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 08:03:23 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Tue Jan 24 08:03:23 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 08:03:23 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 24 08:03:23 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 08:03:23 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 24 08:03:23 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 24 08:03:23 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 08:03:23 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Tue Jan 24 08:03:24 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0045.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 08:03:24 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Tue Jan 24 08:03:24 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 08:03:24 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Tue Jan 24 08:03:24 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Jan 24 08:03:24 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 08:03:24 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Jan 24 08:03:24 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 08:03:25 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Jan 24 08:03:25 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 08:03:25 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Tue Jan 24 08:03:25 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 08:03:26 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Tue Jan 24 08:03:26 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 08:03:26 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 08:03:26 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Tue Jan 24 08:03:26 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 08:03:26 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Tue Jan 24 08:03:27 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0045.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 08:03:27 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Tue Jan 24 08:03:27 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 08:03:27 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Tue Jan 24 08:03:27 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0045.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Jan 24 12:03:23 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 12:03:23 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Jan 24 12:03:23 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Jan 24 12:03:24 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 24 12:03:24 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 12:03:24 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 24 12:03:24 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Tue Jan 24 12:03:24 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Jan 24 12:03:24 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 12:03:24 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Tue Jan 24 12:03:24 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 12:03:24 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Jan 24 12:03:24 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Tue Jan 24 12:03:25 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Tue Jan 24 12:03:25 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Jan 24 12:03:25 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 12:03:25 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Tue Jan 24 12:03:26 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 12:03:26 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 24 12:03:26 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 12:03:27 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 24 12:03:27 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 24 12:03:27 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 12:03:27 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Tue Jan 24 12:03:27 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0046.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 12:03:27 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Tue Jan 24 12:03:27 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 12:03:27 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Tue Jan 24 12:03:27 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Jan 24 12:03:27 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 12:03:28 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Jan 24 12:03:28 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 12:03:28 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Jan 24 12:03:28 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 12:03:28 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Tue Jan 24 12:03:28 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 12:03:28 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Tue Jan 24 12:03:28 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 12:03:28 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 12:03:29 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Tue Jan 24 12:03:29 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 12:03:29 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Tue Jan 24 12:03:29 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0046.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 12:03:29 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Tue Jan 24 12:03:29 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 12:03:29 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Tue Jan 24 12:03:29 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0046.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Jan 24 16:01:35 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 16:01:35 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Jan 24 16:01:35 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Jan 24 16:01:35 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 24 16:01:35 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 16:01:35 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 24 16:01:35 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Tue Jan 24 16:01:35 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Jan 24 16:01:35 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 16:01:36 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Tue Jan 24 16:01:36 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 16:01:36 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Jan 24 16:01:36 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Tue Jan 24 16:01:36 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Tue Jan 24 16:01:36 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Jan 24 16:01:36 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 16:01:36 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Tue Jan 24 16:01:36 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 16:01:36 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 24 16:01:36 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 16:01:36 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 24 16:01:36 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 24 16:01:36 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 16:01:36 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Tue Jan 24 16:01:36 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0047.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 16:01:36 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Tue Jan 24 16:01:36 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 16:01:36 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Tue Jan 24 16:01:36 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Jan 24 16:01:36 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 16:01:36 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Jan 24 16:01:36 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 16:01:37 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Jan 24 16:01:37 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 16:01:37 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Tue Jan 24 16:01:37 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 16:01:37 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Tue Jan 24 16:01:37 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 16:01:37 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 16:01:37 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Tue Jan 24 16:01:37 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 16:01:37 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Tue Jan 24 16:01:37 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0047.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 16:01:37 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Tue Jan 24 16:01:37 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 16:01:37 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Tue Jan 24 16:01:37 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0047.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Jan 24 20:02:02 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 20:02:02 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Jan 24 20:02:02 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Jan 24 20:02:02 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 24 20:02:02 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 20:02:02 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 24 20:02:02 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Tue Jan 24 20:02:02 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Jan 24 20:02:02 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 20:02:02 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Tue Jan 24 20:02:02 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 20:02:02 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Jan 24 20:02:02 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Tue Jan 24 20:02:02 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Tue Jan 24 20:02:02 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Jan 24 20:02:03 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 20:02:03 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Tue Jan 24 20:02:03 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 20:02:03 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 24 20:02:03 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 20:02:04 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 24 20:02:04 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 24 20:02:04 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 20:02:04 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Tue Jan 24 20:02:05 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0048.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 20:02:05 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Tue Jan 24 20:02:05 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 20:02:05 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Tue Jan 24 20:02:05 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Jan 24 20:02:05 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 20:02:05 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Jan 24 20:02:05 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 20:02:05 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Jan 24 20:02:05 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 20:02:05 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Tue Jan 24 20:02:05 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 20:02:05 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Tue Jan 24 20:02:05 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 20:02:05 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 20:02:05 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Tue Jan 24 20:02:05 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 20:02:05 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Tue Jan 24 20:02:05 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0048.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 20:02:05 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Tue Jan 24 20:02:05 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 24 20:02:05 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Tue Jan 24 20:02:05 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0048.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Jan 25 08:02:13 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 08:02:13 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Jan 25 08:02:13 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Jan 25 08:02:13 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Jan 25 08:02:13 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 08:02:13 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Jan 25 08:02:13 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Wed Jan 25 08:02:13 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Jan 25 08:02:13 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 08:02:13 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Wed Jan 25 08:02:13 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 08:02:13 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Jan 25 08:02:13 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Wed Jan 25 08:02:13 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Wed Jan 25 08:02:13 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Jan 25 08:02:13 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 08:02:13 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Wed Jan 25 08:02:13 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 08:02:13 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Jan 25 08:02:13 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 08:02:13 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Jan 25 08:02:13 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Jan 25 08:02:13 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 08:02:13 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Wed Jan 25 08:02:14 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0049.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 08:02:14 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Wed Jan 25 08:02:14 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 08:02:14 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Wed Jan 25 08:02:14 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Jan 25 08:02:14 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 08:02:14 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Jan 25 08:02:14 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 08:02:14 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Jan 25 08:02:14 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 08:02:14 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Wed Jan 25 08:02:14 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 08:02:14 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Wed Jan 25 08:02:14 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 08:02:14 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 08:02:14 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Wed Jan 25 08:02:14 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 08:02:14 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Wed Jan 25 08:02:14 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0049.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 08:02:14 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Wed Jan 25 08:02:14 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 08:02:14 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Wed Jan 25 08:02:14 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0049.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Jan 25 12:01:12 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 12:01:12 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Jan 25 12:01:12 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Jan 25 12:01:12 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Jan 25 12:01:12 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 12:01:12 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Jan 25 12:01:12 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Wed Jan 25 12:01:12 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Jan 25 12:01:12 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 12:01:12 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Wed Jan 25 12:01:12 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 12:01:12 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Jan 25 12:01:12 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Wed Jan 25 12:01:12 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Wed Jan 25 12:01:12 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Jan 25 12:01:12 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 12:01:12 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Wed Jan 25 12:01:12 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 12:01:12 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Jan 25 12:01:12 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 12:01:12 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Jan 25 12:01:12 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Jan 25 12:01:13 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 12:01:13 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Wed Jan 25 12:01:13 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0050.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 12:01:13 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Wed Jan 25 12:01:13 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 12:01:13 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Wed Jan 25 12:01:13 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Jan 25 12:01:13 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 12:01:13 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Jan 25 12:01:13 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 12:01:13 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Jan 25 12:01:13 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 12:01:13 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Wed Jan 25 12:01:13 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 12:01:13 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Wed Jan 25 12:01:13 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 12:01:13 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 12:01:13 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Wed Jan 25 12:01:13 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 12:01:13 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Wed Jan 25 12:01:13 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0050.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 12:01:13 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Wed Jan 25 12:01:13 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 12:01:13 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Wed Jan 25 12:01:13 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0050.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Jan 25 16:01:10 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 16:01:10 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Jan 25 16:01:10 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Jan 25 16:01:10 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Jan 25 16:01:10 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 16:01:10 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Jan 25 16:01:10 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Wed Jan 25 16:01:10 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Jan 25 16:01:10 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 16:01:10 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Wed Jan 25 16:01:10 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 16:01:10 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Jan 25 16:01:10 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Wed Jan 25 16:01:10 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Wed Jan 25 16:01:10 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Jan 25 16:01:10 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 16:01:11 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Wed Jan 25 16:01:11 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 16:01:11 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Jan 25 16:01:11 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 16:01:11 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Jan 25 16:01:11 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Jan 25 16:01:11 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 16:01:11 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Wed Jan 25 16:01:11 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0051.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 16:01:11 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Wed Jan 25 16:01:11 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 16:01:11 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Wed Jan 25 16:01:11 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Jan 25 16:01:11 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 16:01:11 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Jan 25 16:01:11 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 16:01:11 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Jan 25 16:01:11 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 16:01:11 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Wed Jan 25 16:01:11 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 16:01:11 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Wed Jan 25 16:01:11 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 16:01:11 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 16:01:11 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Wed Jan 25 16:01:11 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 16:01:11 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Wed Jan 25 16:01:11 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0051.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 16:01:11 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Wed Jan 25 16:01:11 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 16:01:11 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Wed Jan 25 16:01:11 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0051.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Jan 25 20:01:02 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 20:01:02 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Jan 25 20:01:02 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Jan 25 20:01:02 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Jan 25 20:01:02 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 20:01:02 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Jan 25 20:01:02 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Wed Jan 25 20:01:02 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Jan 25 20:01:02 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 20:01:02 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Wed Jan 25 20:01:02 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 20:01:02 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Jan 25 20:01:02 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Wed Jan 25 20:01:02 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Wed Jan 25 20:01:02 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Jan 25 20:01:02 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 20:01:02 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Wed Jan 25 20:01:02 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 20:01:02 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Jan 25 20:01:02 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 20:01:02 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Jan 25 20:01:02 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Jan 25 20:01:02 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 20:01:02 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Wed Jan 25 20:01:02 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0052.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 20:01:02 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Wed Jan 25 20:01:02 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 20:01:02 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Wed Jan 25 20:01:02 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Jan 25 20:01:02 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 20:01:02 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Jan 25 20:01:02 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 20:01:02 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Jan 25 20:01:02 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 20:01:02 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Wed Jan 25 20:01:02 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 20:01:02 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Wed Jan 25 20:01:02 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 20:01:03 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 20:01:03 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Wed Jan 25 20:01:03 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 20:01:03 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Wed Jan 25 20:01:03 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0052.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 20:01:03 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Wed Jan 25 20:01:03 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Jan 25 20:01:03 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Wed Jan 25 20:01:03 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0052.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Jan 26 08:06:14 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 08:06:14 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Jan 26 08:06:14 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Jan 26 08:06:14 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Jan 26 08:06:14 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 08:06:14 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Jan 26 08:06:14 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Thu Jan 26 08:06:14 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Jan 26 08:06:14 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 08:06:14 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Thu Jan 26 08:06:14 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 08:06:14 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Jan 26 08:06:14 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Thu Jan 26 08:06:14 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Thu Jan 26 08:06:15 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Jan 26 08:06:15 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 08:06:15 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Thu Jan 26 08:06:15 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 08:06:15 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Jan 26 08:06:15 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 08:06:15 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Jan 26 08:06:15 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Jan 26 08:06:16 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 08:06:16 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Thu Jan 26 08:06:19 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0053.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 08:06:19 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Thu Jan 26 08:06:20 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 08:06:20 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Thu Jan 26 08:06:20 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Jan 26 08:06:20 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 08:06:20 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Jan 26 08:06:20 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 08:06:20 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Jan 26 08:06:20 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 08:06:20 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Thu Jan 26 08:06:20 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 08:06:20 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Thu Jan 26 08:06:20 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 08:06:20 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 08:06:20 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Thu Jan 26 08:06:21 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 08:06:21 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Thu Jan 26 08:06:21 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0053.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 08:06:21 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Thu Jan 26 08:06:21 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 08:06:21 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Thu Jan 26 08:06:22 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0053.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Jan 26 12:01:14 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 12:01:14 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Jan 26 12:01:14 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Jan 26 12:01:14 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Jan 26 12:01:14 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 12:01:14 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Jan 26 12:01:14 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Thu Jan 26 12:01:14 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Jan 26 12:01:14 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 12:01:14 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Thu Jan 26 12:01:14 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 12:01:14 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Jan 26 12:01:14 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Thu Jan 26 12:01:14 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Thu Jan 26 12:01:14 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Jan 26 12:01:14 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 12:01:14 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Thu Jan 26 12:01:14 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 12:01:14 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Jan 26 12:01:14 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 12:01:14 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Jan 26 12:01:14 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Jan 26 12:01:14 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 12:01:14 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Thu Jan 26 12:01:14 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0054.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 12:01:14 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Thu Jan 26 12:01:14 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 12:01:14 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Thu Jan 26 12:01:14 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Jan 26 12:01:14 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 12:01:14 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Jan 26 12:01:15 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 12:01:15 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Jan 26 12:01:15 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 12:01:15 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Thu Jan 26 12:01:15 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 12:01:15 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Thu Jan 26 12:01:15 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 12:01:15 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 12:01:15 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Thu Jan 26 12:01:15 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 12:01:15 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Thu Jan 26 12:01:15 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0054.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 12:01:15 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Thu Jan 26 12:01:15 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 12:01:15 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Thu Jan 26 12:01:15 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0054.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Jan 26 16:01:00 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 16:01:00 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Jan 26 16:01:00 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Jan 26 16:01:00 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Jan 26 16:01:00 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 16:01:00 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Jan 26 16:01:00 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Thu Jan 26 16:01:00 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Jan 26 16:01:00 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 16:01:00 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Thu Jan 26 16:01:00 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 16:01:00 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Jan 26 16:01:00 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Thu Jan 26 16:01:00 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Thu Jan 26 16:01:00 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Jan 26 16:01:00 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 16:01:00 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Thu Jan 26 16:01:00 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 16:01:00 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Jan 26 16:01:00 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 16:01:00 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Jan 26 16:01:00 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Jan 26 16:01:00 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 16:01:00 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Thu Jan 26 16:01:00 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0055.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 16:01:00 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Thu Jan 26 16:01:00 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 16:01:00 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Thu Jan 26 16:01:00 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Jan 26 16:01:00 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 16:01:00 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Jan 26 16:01:00 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 16:01:00 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Jan 26 16:01:00 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 16:01:00 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Thu Jan 26 16:01:00 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 16:01:00 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Thu Jan 26 16:01:00 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 16:01:00 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 16:01:01 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Thu Jan 26 16:01:01 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 16:01:01 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Thu Jan 26 16:01:01 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0055.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 16:01:01 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Thu Jan 26 16:01:01 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 16:01:01 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Thu Jan 26 16:01:01 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0055.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Jan 26 20:00:52 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0056.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0056.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Thu Jan 26 20:00:53 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0056.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Jan 27 08:07:14 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 08:07:15 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Jan 27 08:07:16 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Jan 27 08:07:16 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 27 08:07:16 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 08:07:16 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 27 08:07:16 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Fri Jan 27 08:07:16 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Jan 27 08:07:17 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 08:07:17 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Fri Jan 27 08:07:17 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 08:07:17 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Jan 27 08:07:17 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Fri Jan 27 08:07:17 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Fri Jan 27 08:07:18 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Jan 27 08:07:18 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 08:07:18 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Fri Jan 27 08:07:18 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 08:07:19 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 27 08:07:19 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 08:07:19 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 27 08:07:19 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 27 08:07:19 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 08:07:19 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Fri Jan 27 08:07:24 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0057.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 08:07:24 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Fri Jan 27 08:07:24 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 08:07:24 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Fri Jan 27 08:07:24 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Jan 27 08:07:24 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 08:07:24 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Jan 27 08:07:25 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 08:07:25 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Jan 27 08:07:25 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 08:07:25 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Fri Jan 27 08:07:25 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 08:07:25 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Fri Jan 27 08:07:25 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 08:07:25 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 08:07:25 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Fri Jan 27 08:07:25 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 08:07:25 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Fri Jan 27 08:07:25 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0057.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 08:07:25 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Fri Jan 27 08:07:25 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 08:07:25 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Fri Jan 27 08:07:26 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0057.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Jan 27 12:02:22 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 12:02:22 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Jan 27 12:02:22 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Jan 27 12:02:22 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 27 12:02:22 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 12:02:22 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 27 12:02:22 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Fri Jan 27 12:02:22 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Jan 27 12:02:22 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 12:02:22 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Fri Jan 27 12:02:22 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 12:02:22 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Jan 27 12:02:22 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Fri Jan 27 12:02:22 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Fri Jan 27 12:02:22 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Jan 27 12:02:22 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 12:02:22 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Fri Jan 27 12:02:22 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 12:02:22 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 27 12:02:22 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 12:02:22 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 27 12:02:22 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 27 12:02:22 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 12:02:22 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Fri Jan 27 12:02:22 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0058.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 12:02:22 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Fri Jan 27 12:02:22 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 12:02:22 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Fri Jan 27 12:02:22 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Jan 27 12:02:22 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 12:02:22 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Jan 27 12:02:23 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 12:02:23 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Jan 27 12:02:23 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 12:02:23 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Fri Jan 27 12:02:23 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 12:02:23 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Fri Jan 27 12:02:23 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 12:02:23 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 12:02:23 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Fri Jan 27 12:02:23 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 12:02:23 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Fri Jan 27 12:02:23 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0058.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 12:02:23 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Fri Jan 27 12:02:23 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 12:02:23 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Fri Jan 27 12:02:23 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0058.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Jan 27 16:01:14 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 16:01:14 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Jan 27 16:01:14 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Jan 27 16:01:14 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 27 16:01:14 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 16:01:14 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 27 16:01:14 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Fri Jan 27 16:01:14 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Jan 27 16:01:14 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 16:01:14 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Fri Jan 27 16:01:14 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 16:01:14 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Jan 27 16:01:14 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Fri Jan 27 16:01:14 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Fri Jan 27 16:01:14 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Jan 27 16:01:14 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 16:01:14 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Fri Jan 27 16:01:14 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 16:01:14 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 27 16:01:14 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 16:01:14 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 27 16:01:14 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 27 16:01:14 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 16:01:14 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Fri Jan 27 16:01:14 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0059.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 16:01:14 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Fri Jan 27 16:01:14 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 16:01:14 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Fri Jan 27 16:01:14 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Jan 27 16:01:14 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 16:01:14 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Jan 27 16:01:14 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 16:01:14 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Jan 27 16:01:14 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 16:01:14 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Fri Jan 27 16:01:14 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 16:01:14 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Fri Jan 27 16:01:14 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 16:01:14 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 16:01:14 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Fri Jan 27 16:01:14 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 16:01:14 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Fri Jan 27 16:01:14 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0059.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 16:01:15 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Fri Jan 27 16:01:15 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 16:01:15 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Fri Jan 27 16:01:15 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0059.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Jan 27 20:01:06 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 20:01:06 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Jan 27 20:01:06 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Jan 27 20:01:06 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 27 20:01:06 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 20:01:06 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 27 20:01:06 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Fri Jan 27 20:01:06 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Jan 27 20:01:06 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 20:01:06 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Fri Jan 27 20:01:06 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 20:01:06 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Jan 27 20:01:06 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Fri Jan 27 20:01:06 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Fri Jan 27 20:01:06 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Jan 27 20:01:06 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 20:01:06 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Fri Jan 27 20:01:06 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 20:01:06 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 27 20:01:06 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 20:01:06 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 27 20:01:06 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Jan 27 20:01:06 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 20:01:06 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Fri Jan 27 20:01:07 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0060.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 20:01:07 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Fri Jan 27 20:01:07 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 20:01:07 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Fri Jan 27 20:01:07 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Jan 27 20:01:07 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 20:01:07 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Jan 27 20:01:07 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 20:01:07 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Jan 27 20:01:07 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 20:01:07 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Fri Jan 27 20:01:07 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 20:01:07 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Fri Jan 27 20:01:07 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 20:01:07 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 20:01:07 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Fri Jan 27 20:01:07 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 20:01:07 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Fri Jan 27 20:01:07 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0060.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 20:01:07 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Fri Jan 27 20:01:07 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Jan 27 20:01:07 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Fri Jan 27 20:01:07 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0060.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Jan 28 08:06:01 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 08:06:01 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Jan 28 08:06:01 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Jan 28 08:06:02 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 28 08:06:02 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 08:06:02 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 28 08:06:02 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sat Jan 28 08:06:02 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Jan 28 08:06:02 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 08:06:02 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Sat Jan 28 08:06:02 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 08:06:02 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Jan 28 08:06:02 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sat Jan 28 08:06:02 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Sat Jan 28 08:06:02 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Jan 28 08:06:02 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 08:06:02 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Sat Jan 28 08:06:02 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 08:06:02 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 28 08:06:03 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 08:06:03 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 28 08:06:03 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 28 08:06:03 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 08:06:03 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Sat Jan 28 08:06:04 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0061.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 08:06:05 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Sat Jan 28 08:06:05 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 08:06:05 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Sat Jan 28 08:06:05 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Jan 28 08:06:05 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 08:06:05 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Jan 28 08:06:05 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 08:06:05 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Jan 28 08:06:05 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 08:06:05 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Sat Jan 28 08:06:06 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 08:06:06 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Sat Jan 28 08:06:06 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 08:06:06 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 08:06:06 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Sat Jan 28 08:06:06 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 08:06:06 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sat Jan 28 08:06:06 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0061.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 08:06:06 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Sat Jan 28 08:06:06 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 08:06:06 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sat Jan 28 08:06:07 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0061.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Jan 28 12:02:02 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 12:02:02 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Jan 28 12:02:02 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Jan 28 12:02:02 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 28 12:02:02 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 12:02:02 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 28 12:02:02 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sat Jan 28 12:02:02 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Jan 28 12:02:02 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 12:02:02 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Sat Jan 28 12:02:02 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 12:02:02 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Jan 28 12:02:02 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sat Jan 28 12:02:02 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Sat Jan 28 12:02:02 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Jan 28 12:02:02 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 12:02:02 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Sat Jan 28 12:02:02 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 12:02:03 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 28 12:02:03 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 12:02:03 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 28 12:02:03 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 28 12:02:03 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 12:02:03 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Sat Jan 28 12:02:03 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0062.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 12:02:03 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Sat Jan 28 12:02:03 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 12:02:03 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Sat Jan 28 12:02:03 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Jan 28 12:02:03 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 12:02:03 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Jan 28 12:02:03 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 12:02:03 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Jan 28 12:02:03 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 12:02:03 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Sat Jan 28 12:02:03 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 12:02:03 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Sat Jan 28 12:02:03 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 12:02:03 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 12:02:03 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Sat Jan 28 12:02:03 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 12:02:03 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sat Jan 28 12:02:03 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0062.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 12:02:03 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Sat Jan 28 12:02:03 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 12:02:03 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sat Jan 28 12:02:03 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0062.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Jan 28 16:01:02 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 16:01:02 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Jan 28 16:01:02 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Jan 28 16:01:02 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 28 16:01:02 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 16:01:02 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 28 16:01:02 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sat Jan 28 16:01:02 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Jan 28 16:01:02 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 16:01:02 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Sat Jan 28 16:01:02 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 16:01:02 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Jan 28 16:01:02 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sat Jan 28 16:01:02 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Sat Jan 28 16:01:02 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Jan 28 16:01:02 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 16:01:02 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Sat Jan 28 16:01:02 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 16:01:02 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 28 16:01:02 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 16:01:02 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 28 16:01:02 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 28 16:01:02 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 16:01:02 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Sat Jan 28 16:01:02 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0063.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 16:01:02 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Sat Jan 28 16:01:03 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 16:01:03 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Sat Jan 28 16:01:03 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Jan 28 16:01:03 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 16:01:03 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Jan 28 16:01:04 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 16:01:04 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Jan 28 16:01:04 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 16:01:04 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Sat Jan 28 16:01:04 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 16:01:04 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Sat Jan 28 16:01:04 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 16:01:04 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 16:01:04 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Sat Jan 28 16:01:04 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 16:01:04 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sat Jan 28 16:01:04 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0063.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 16:01:04 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Sat Jan 28 16:01:04 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 16:01:04 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sat Jan 28 16:01:04 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0063.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Jan 28 20:01:02 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 20:01:02 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Jan 28 20:01:02 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Jan 28 20:01:02 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 28 20:01:02 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 20:01:02 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 28 20:01:02 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sat Jan 28 20:01:02 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Jan 28 20:01:02 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 20:01:02 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Sat Jan 28 20:01:02 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 20:01:02 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Jan 28 20:01:02 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sat Jan 28 20:01:02 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Sat Jan 28 20:01:02 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Jan 28 20:01:02 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 20:01:02 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Sat Jan 28 20:01:02 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 20:01:03 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 28 20:01:03 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 20:01:03 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 28 20:01:03 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Jan 28 20:01:03 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 20:01:03 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Sat Jan 28 20:01:03 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0064.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 20:01:03 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Sat Jan 28 20:01:03 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 20:01:03 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Sat Jan 28 20:01:03 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Jan 28 20:01:03 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 20:01:03 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Jan 28 20:01:03 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 20:01:03 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Jan 28 20:01:03 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 20:01:03 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Sat Jan 28 20:01:03 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 20:01:03 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Sat Jan 28 20:01:03 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 20:01:03 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 20:01:03 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Sat Jan 28 20:01:03 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 20:01:03 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sat Jan 28 20:01:03 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0064.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 20:01:03 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Sat Jan 28 20:01:03 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Jan 28 20:01:03 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sat Jan 28 20:01:03 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0064.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Jan 29 08:07:44 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 08:07:44 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Jan 29 08:07:44 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Jan 29 08:07:44 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 29 08:07:44 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 08:07:44 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 29 08:07:44 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sun Jan 29 08:07:45 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Jan 29 08:07:45 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 08:07:45 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Sun Jan 29 08:07:45 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 08:07:45 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Jan 29 08:07:45 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sun Jan 29 08:07:45 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Sun Jan 29 08:07:45 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Jan 29 08:07:45 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 08:07:45 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Sun Jan 29 08:07:45 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 08:07:45 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 29 08:07:45 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 08:07:45 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 29 08:07:45 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 29 08:07:45 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 08:07:45 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Sun Jan 29 08:07:46 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0065.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 08:07:46 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Sun Jan 29 08:07:46 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 08:07:46 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Sun Jan 29 08:07:46 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Jan 29 08:07:46 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 08:07:46 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Jan 29 08:07:46 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 08:07:46 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Jan 29 08:07:46 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 08:07:46 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Sun Jan 29 08:07:46 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 08:07:46 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Sun Jan 29 08:07:46 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 08:07:46 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 08:07:46 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Sun Jan 29 08:07:46 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 08:07:46 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sun Jan 29 08:07:46 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0065.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 08:07:46 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Sun Jan 29 08:07:46 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 08:07:47 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sun Jan 29 08:07:47 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0065.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Jan 29 12:01:08 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 12:01:08 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Jan 29 12:01:08 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Jan 29 12:01:08 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 29 12:01:08 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 12:01:08 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 29 12:01:08 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sun Jan 29 12:01:08 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Jan 29 12:01:08 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 12:01:08 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Sun Jan 29 12:01:08 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 12:01:08 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Jan 29 12:01:08 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sun Jan 29 12:01:08 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Sun Jan 29 12:01:08 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Jan 29 12:01:08 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 12:01:09 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Sun Jan 29 12:01:09 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 12:01:09 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 29 12:01:09 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 12:01:09 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 29 12:01:09 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 29 12:01:09 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 12:01:09 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Sun Jan 29 12:01:09 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0066.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 12:01:09 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Sun Jan 29 12:01:09 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 12:01:09 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Sun Jan 29 12:01:09 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Jan 29 12:01:09 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 12:01:09 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Jan 29 12:01:09 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 12:01:09 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Jan 29 12:01:09 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 12:01:09 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Sun Jan 29 12:01:09 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 12:01:11 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Sun Jan 29 12:01:11 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 12:01:11 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 12:01:11 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Sun Jan 29 12:01:11 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 12:01:11 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sun Jan 29 12:01:11 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0066.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 12:01:11 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Sun Jan 29 12:01:11 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 12:01:11 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sun Jan 29 12:01:11 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0066.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Jan 29 16:01:00 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 16:01:00 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Jan 29 16:01:00 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Jan 29 16:01:00 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 29 16:01:00 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 16:01:00 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 29 16:01:00 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sun Jan 29 16:01:00 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Jan 29 16:01:00 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 16:01:00 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Sun Jan 29 16:01:00 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 16:01:00 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Jan 29 16:01:00 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sun Jan 29 16:01:00 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Sun Jan 29 16:01:00 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Jan 29 16:01:00 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 16:01:00 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Sun Jan 29 16:01:00 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 16:01:00 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 29 16:01:00 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 16:01:00 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 29 16:01:00 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 29 16:01:00 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 16:01:00 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Sun Jan 29 16:01:00 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0067.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 16:01:00 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Sun Jan 29 16:01:00 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 16:01:00 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Sun Jan 29 16:01:00 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Jan 29 16:01:00 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 16:01:00 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Jan 29 16:01:00 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 16:01:00 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Jan 29 16:01:00 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 16:01:01 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Sun Jan 29 16:01:01 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 16:01:01 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Sun Jan 29 16:01:01 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 16:01:01 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 16:01:01 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Sun Jan 29 16:01:01 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 16:01:01 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sun Jan 29 16:01:01 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0067.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 16:01:01 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Sun Jan 29 16:01:01 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 16:01:01 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sun Jan 29 16:01:01 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0067.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Jan 29 20:01:03 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 20:01:03 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Jan 29 20:01:03 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Jan 29 20:01:03 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 29 20:01:03 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 20:01:03 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 29 20:01:03 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sun Jan 29 20:01:03 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Jan 29 20:01:03 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 20:01:03 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Sun Jan 29 20:01:03 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 20:01:03 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Jan 29 20:01:03 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sun Jan 29 20:01:03 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Sun Jan 29 20:01:03 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Jan 29 20:01:03 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 20:01:03 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Sun Jan 29 20:01:03 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 20:01:03 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 29 20:01:03 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 20:01:03 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 29 20:01:03 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Jan 29 20:01:03 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 20:01:03 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Sun Jan 29 20:01:03 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0068.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 20:01:03 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Sun Jan 29 20:01:03 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 20:01:03 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Sun Jan 29 20:01:03 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Jan 29 20:01:03 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 20:01:03 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Jan 29 20:01:03 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 20:01:03 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Jan 29 20:01:03 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 20:01:03 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Sun Jan 29 20:01:03 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 20:01:03 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Sun Jan 29 20:01:03 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 20:01:03 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 20:01:03 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Sun Jan 29 20:01:03 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 20:01:03 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sun Jan 29 20:01:03 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0068.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 20:01:04 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Sun Jan 29 20:01:04 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Jan 29 20:01:04 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sun Jan 29 20:01:04 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0068.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Jan 30 08:09:38 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 08:09:39 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Jan 30 08:09:39 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Jan 30 08:09:40 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 30 08:09:40 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 08:09:40 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 30 08:09:40 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Mon Jan 30 08:09:40 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Jan 30 08:09:41 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 08:09:41 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Mon Jan 30 08:09:41 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 08:09:41 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Jan 30 08:09:41 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Mon Jan 30 08:09:41 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Mon Jan 30 08:09:41 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Jan 30 08:09:41 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 08:09:42 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Mon Jan 30 08:09:42 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 08:09:42 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 30 08:09:42 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 08:09:43 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 30 08:09:43 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 30 08:09:43 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 08:09:43 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Mon Jan 30 08:09:47 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0069.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 08:09:47 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Mon Jan 30 08:09:47 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 08:09:47 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Mon Jan 30 08:09:48 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Jan 30 08:09:48 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 08:09:48 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Jan 30 08:09:48 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 08:09:48 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Jan 30 08:09:48 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 08:09:48 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Mon Jan 30 08:09:48 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 08:09:48 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Mon Jan 30 08:09:49 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 08:09:49 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 08:09:49 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Mon Jan 30 08:09:49 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 08:09:49 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Mon Jan 30 08:09:50 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0069.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 08:09:50 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Mon Jan 30 08:09:50 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 08:09:50 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Mon Jan 30 08:09:53 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0069.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Jan 30 12:04:09 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 12:04:09 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Jan 30 12:04:09 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Jan 30 12:04:09 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 30 12:04:09 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 12:04:09 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 30 12:04:09 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Mon Jan 30 12:04:09 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Jan 30 12:04:09 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 12:04:09 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Mon Jan 30 12:04:09 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 12:04:09 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Jan 30 12:04:10 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Mon Jan 30 12:04:10 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Mon Jan 30 12:04:10 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Jan 30 12:04:10 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 12:04:10 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Mon Jan 30 12:04:10 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 12:04:10 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 30 12:04:10 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 12:04:10 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 30 12:04:10 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 30 12:04:10 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 12:04:10 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Mon Jan 30 12:04:11 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0070.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 12:04:11 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Mon Jan 30 12:04:11 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 12:04:11 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Mon Jan 30 12:04:11 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Jan 30 12:04:11 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 12:04:11 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Jan 30 12:04:11 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 12:04:11 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Jan 30 12:04:11 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 12:04:11 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Mon Jan 30 12:04:11 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 12:04:11 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Mon Jan 30 12:04:11 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 12:04:11 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 12:04:11 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Mon Jan 30 12:04:11 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 12:04:11 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Mon Jan 30 12:04:11 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0070.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 12:04:12 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Mon Jan 30 12:04:12 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 12:04:12 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Mon Jan 30 12:04:12 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0070.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Jan 30 16:04:26 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 16:04:26 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Jan 30 16:04:26 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Jan 30 16:04:26 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 30 16:04:26 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 16:04:26 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 30 16:04:26 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Mon Jan 30 16:04:26 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Jan 30 16:04:27 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 16:04:27 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Mon Jan 30 16:04:27 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 16:04:27 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Jan 30 16:04:27 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Mon Jan 30 16:04:27 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Mon Jan 30 16:04:27 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Jan 30 16:04:27 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 16:04:27 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Mon Jan 30 16:04:27 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 16:04:27 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 30 16:04:27 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 16:04:27 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 30 16:04:27 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 30 16:04:27 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 16:04:27 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Mon Jan 30 16:04:28 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0071.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 16:04:28 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Mon Jan 30 16:04:28 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 16:04:28 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Mon Jan 30 16:04:28 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Jan 30 16:04:28 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 16:04:28 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Jan 30 16:04:28 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 16:04:28 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Jan 30 16:04:29 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 16:04:29 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Mon Jan 30 16:04:29 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 16:04:29 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Mon Jan 30 16:04:29 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 16:04:29 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 16:04:29 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Mon Jan 30 16:04:29 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 16:04:29 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Mon Jan 30 16:04:29 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0071.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 16:04:29 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Mon Jan 30 16:04:29 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 16:04:29 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Mon Jan 30 16:04:29 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0071.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Jan 30 20:02:25 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 20:02:25 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Jan 30 20:02:25 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Jan 30 20:02:25 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 30 20:02:25 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 20:02:25 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 30 20:02:25 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Mon Jan 30 20:02:25 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Jan 30 20:02:25 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 20:02:25 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Mon Jan 30 20:02:25 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 20:02:25 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Jan 30 20:02:25 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Mon Jan 30 20:02:25 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Mon Jan 30 20:02:25 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Jan 30 20:02:25 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 20:02:25 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Mon Jan 30 20:02:25 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 20:02:25 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 30 20:02:25 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 20:02:25 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 30 20:02:26 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Jan 30 20:02:26 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 20:02:26 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Mon Jan 30 20:02:26 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0072.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 20:02:26 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Mon Jan 30 20:02:27 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 20:02:27 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Mon Jan 30 20:02:27 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Jan 30 20:02:27 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 20:02:27 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Jan 30 20:02:27 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 20:02:27 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Jan 30 20:02:27 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 20:02:27 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Mon Jan 30 20:02:27 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 20:02:27 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Mon Jan 30 20:02:27 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 20:02:27 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 20:02:27 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Mon Jan 30 20:02:27 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 20:02:27 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Mon Jan 30 20:02:27 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0072.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 20:02:27 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Mon Jan 30 20:02:27 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Jan 30 20:02:27 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Mon Jan 30 20:02:27 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0072.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Jan 31 08:08:12 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 08:08:12 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Jan 31 08:08:12 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Jan 31 08:08:12 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 31 08:08:12 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 08:08:12 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 31 08:08:12 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Tue Jan 31 08:08:12 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Jan 31 08:08:13 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 08:08:13 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Tue Jan 31 08:08:13 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 08:08:13 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Jan 31 08:08:13 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Tue Jan 31 08:08:13 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Tue Jan 31 08:08:13 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Jan 31 08:08:13 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 08:08:13 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Tue Jan 31 08:08:13 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 08:08:13 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 31 08:08:13 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 08:08:13 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 31 08:08:13 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 31 08:08:13 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 08:08:13 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Tue Jan 31 08:08:21 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0073.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 08:08:21 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Tue Jan 31 08:08:21 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 08:08:21 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Tue Jan 31 08:08:21 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Jan 31 08:08:21 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 08:08:21 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Jan 31 08:08:21 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 08:08:21 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Jan 31 08:08:21 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 08:08:21 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Tue Jan 31 08:08:21 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 08:08:21 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Tue Jan 31 08:08:22 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 08:08:22 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 08:08:22 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Tue Jan 31 08:08:22 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 08:08:22 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Tue Jan 31 08:08:22 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0073.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 08:08:22 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Tue Jan 31 08:08:22 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 08:08:22 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Tue Jan 31 08:08:22 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0073.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Jan 31 12:04:31 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 12:04:31 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Jan 31 12:04:31 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Jan 31 12:04:31 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 31 12:04:31 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 12:04:31 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 31 12:04:31 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Tue Jan 31 12:04:31 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Jan 31 12:04:31 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 12:04:31 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Tue Jan 31 12:04:31 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 12:04:31 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Jan 31 12:04:31 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Tue Jan 31 12:04:31 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Tue Jan 31 12:04:31 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Jan 31 12:04:31 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 12:04:32 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Tue Jan 31 12:04:32 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 12:04:32 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 31 12:04:32 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 12:04:32 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 31 12:04:32 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 31 12:04:32 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 12:04:32 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Tue Jan 31 12:04:33 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0074.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 12:04:33 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Tue Jan 31 12:04:33 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 12:04:33 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Tue Jan 31 12:04:33 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Jan 31 12:04:33 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 12:04:33 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Jan 31 12:04:33 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 12:04:33 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Jan 31 12:04:33 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 12:04:33 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Tue Jan 31 12:04:33 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 12:04:36 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Tue Jan 31 12:04:36 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 12:04:36 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 12:04:36 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Tue Jan 31 12:04:36 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 12:04:37 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Tue Jan 31 12:04:37 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0074.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 12:04:37 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Tue Jan 31 12:04:37 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 12:04:37 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Tue Jan 31 12:04:38 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0074.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Jan 31 16:02:31 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 16:02:31 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Jan 31 16:02:31 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Jan 31 16:02:31 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 31 16:02:31 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 16:02:31 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 31 16:02:31 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Tue Jan 31 16:02:31 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Jan 31 16:02:31 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 16:02:31 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Tue Jan 31 16:02:31 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 16:02:32 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Jan 31 16:02:32 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Tue Jan 31 16:02:32 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Tue Jan 31 16:02:32 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Jan 31 16:02:33 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 16:02:34 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Tue Jan 31 16:02:34 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 16:02:34 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 31 16:02:34 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 16:02:34 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 31 16:02:34 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 31 16:02:34 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 16:02:34 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Tue Jan 31 16:02:35 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0075.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 16:02:35 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Tue Jan 31 16:02:35 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 16:02:35 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Tue Jan 31 16:02:35 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Jan 31 16:02:35 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 16:02:35 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Jan 31 16:02:35 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 16:02:35 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Jan 31 16:02:35 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 16:02:35 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Tue Jan 31 16:02:35 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 16:02:35 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Tue Jan 31 16:02:35 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 16:02:35 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 16:02:35 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Tue Jan 31 16:02:35 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 16:02:35 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Tue Jan 31 16:02:35 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0075.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 16:02:35 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Tue Jan 31 16:02:35 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 16:02:35 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Tue Jan 31 16:02:36 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0075.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Jan 31 20:01:16 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 20:01:16 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Jan 31 20:01:16 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Jan 31 20:01:16 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 31 20:01:16 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 20:01:16 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 31 20:01:16 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Tue Jan 31 20:01:16 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Jan 31 20:01:16 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 20:01:16 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Tue Jan 31 20:01:16 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 20:01:16 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Jan 31 20:01:16 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Tue Jan 31 20:01:16 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Tue Jan 31 20:01:16 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Jan 31 20:01:16 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 20:01:16 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Tue Jan 31 20:01:16 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 20:01:16 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 31 20:01:16 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 20:01:16 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 31 20:01:16 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Jan 31 20:01:16 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 20:01:16 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Tue Jan 31 20:01:16 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0076.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 20:01:16 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Tue Jan 31 20:01:16 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 20:01:16 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Tue Jan 31 20:01:17 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Jan 31 20:01:17 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 20:01:17 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Jan 31 20:01:17 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 20:01:17 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Jan 31 20:01:17 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 20:01:17 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Tue Jan 31 20:01:17 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 20:01:17 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Tue Jan 31 20:01:17 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 20:01:17 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 20:01:17 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Tue Jan 31 20:01:17 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 20:01:17 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Tue Jan 31 20:01:17 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0076.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 20:01:17 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Tue Jan 31 20:01:17 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Jan 31 20:01:17 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Tue Jan 31 20:01:17 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0076.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Feb 1 08:10:20 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 08:10:21 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Feb 1 08:10:21 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Feb 1 08:10:21 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 1 08:10:21 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 08:10:21 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 1 08:10:21 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Wed Feb 1 08:10:21 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Feb 1 08:10:21 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 08:10:21 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Wed Feb 1 08:10:21 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 08:10:21 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Feb 1 08:10:21 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Wed Feb 1 08:10:21 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Wed Feb 1 08:10:21 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Feb 1 08:10:21 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 08:10:21 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Wed Feb 1 08:10:21 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 08:10:22 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 1 08:10:22 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 08:10:22 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 1 08:10:22 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 1 08:10:22 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 08:10:22 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Wed Feb 1 08:10:25 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0077.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 08:10:25 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Wed Feb 1 08:10:25 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 08:10:25 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Wed Feb 1 08:10:25 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Feb 1 08:10:25 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 08:10:25 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Feb 1 08:10:26 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 08:10:26 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Feb 1 08:10:27 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 08:10:27 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Wed Feb 1 08:10:28 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 08:10:28 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Wed Feb 1 08:10:28 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 08:10:28 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 08:10:28 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Wed Feb 1 08:10:28 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 08:10:29 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Wed Feb 1 08:10:29 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0077.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 08:10:29 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Wed Feb 1 08:10:29 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 08:10:29 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Wed Feb 1 08:10:30 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0077.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Feb 1 12:02:55 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 12:02:55 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Feb 1 12:02:55 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Feb 1 12:02:55 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 1 12:02:55 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 12:02:55 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 1 12:02:55 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Wed Feb 1 12:02:55 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Feb 1 12:02:55 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 12:02:55 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Wed Feb 1 12:02:55 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 12:02:55 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Feb 1 12:02:55 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Wed Feb 1 12:02:55 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Wed Feb 1 12:02:55 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Feb 1 12:02:55 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 12:02:55 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Wed Feb 1 12:02:55 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 12:02:55 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 1 12:02:55 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 12:02:55 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 1 12:02:55 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 1 12:02:55 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 12:02:55 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Wed Feb 1 12:02:56 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0078.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 12:02:56 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Wed Feb 1 12:02:56 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 12:02:56 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Wed Feb 1 12:02:56 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Feb 1 12:02:56 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 12:02:56 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Feb 1 12:02:56 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 12:02:57 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Feb 1 12:02:57 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 12:02:57 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Wed Feb 1 12:02:57 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 12:02:57 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Wed Feb 1 12:02:57 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 12:02:57 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 12:02:57 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Wed Feb 1 12:02:57 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 12:02:57 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Wed Feb 1 12:02:57 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0078.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 12:02:57 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Wed Feb 1 12:02:57 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 12:02:57 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Wed Feb 1 12:02:57 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0078.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Feb 1 16:01:15 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 16:01:15 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Feb 1 16:01:15 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Feb 1 16:01:15 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 1 16:01:15 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 16:01:15 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 1 16:01:15 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Wed Feb 1 16:01:15 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Feb 1 16:01:15 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 16:01:15 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Wed Feb 1 16:01:15 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 16:01:15 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Feb 1 16:01:15 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Wed Feb 1 16:01:15 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Wed Feb 1 16:01:15 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Feb 1 16:01:15 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 16:01:15 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Wed Feb 1 16:01:15 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 16:01:15 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 1 16:01:15 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 16:01:15 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 1 16:01:15 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 1 16:01:15 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 16:01:15 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Wed Feb 1 16:01:15 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0079.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 16:01:15 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Wed Feb 1 16:01:15 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 16:01:15 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Wed Feb 1 16:01:15 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Feb 1 16:01:15 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 16:01:15 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Feb 1 16:01:15 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 16:01:15 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Feb 1 16:01:15 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 16:01:16 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Wed Feb 1 16:01:16 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 16:01:16 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Wed Feb 1 16:01:16 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 16:01:16 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 16:01:16 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Wed Feb 1 16:01:16 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 16:01:16 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Wed Feb 1 16:01:16 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0079.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 16:01:16 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Wed Feb 1 16:01:16 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 16:01:16 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Wed Feb 1 16:01:16 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0079.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Feb 1 20:01:12 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 20:01:12 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Feb 1 20:01:12 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Feb 1 20:01:12 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 1 20:01:12 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 20:01:12 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 1 20:01:12 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Wed Feb 1 20:01:12 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Feb 1 20:01:12 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 20:01:12 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Wed Feb 1 20:01:12 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 20:01:12 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Feb 1 20:01:12 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Wed Feb 1 20:01:12 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Wed Feb 1 20:01:12 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Feb 1 20:01:12 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 20:01:12 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Wed Feb 1 20:01:12 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 20:01:12 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 1 20:01:12 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 20:01:12 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 1 20:01:12 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 1 20:01:12 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 20:01:12 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Wed Feb 1 20:01:12 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0080.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 20:01:12 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Wed Feb 1 20:01:12 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 20:01:12 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Wed Feb 1 20:01:12 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Feb 1 20:01:12 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 20:01:12 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Feb 1 20:01:12 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 20:01:12 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Feb 1 20:01:12 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 20:01:12 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Wed Feb 1 20:01:12 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 20:01:12 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Wed Feb 1 20:01:12 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 20:01:12 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 20:01:12 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Wed Feb 1 20:01:12 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 20:01:12 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Wed Feb 1 20:01:12 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0080.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 20:01:12 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Wed Feb 1 20:01:12 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 1 20:01:13 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Wed Feb 1 20:01:13 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0080.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Feb 2 08:13:47 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 08:13:49 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Feb 2 08:13:49 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Feb 2 08:13:49 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Feb 2 08:13:49 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 08:13:50 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Feb 2 08:13:50 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Thu Feb 2 08:13:50 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Feb 2 08:13:50 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 08:13:50 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Thu Feb 2 08:13:51 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 08:13:51 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Feb 2 08:13:51 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Thu Feb 2 08:13:51 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Thu Feb 2 08:13:51 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Feb 2 08:13:51 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 08:13:53 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Thu Feb 2 08:13:53 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 08:13:53 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Feb 2 08:13:53 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 08:13:53 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Feb 2 08:13:54 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Feb 2 08:13:54 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 08:13:54 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Thu Feb 2 08:13:58 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0081.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 08:13:58 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Thu Feb 2 08:13:59 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 08:13:59 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Thu Feb 2 08:13:59 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Feb 2 08:13:59 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 08:13:59 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Feb 2 08:14:00 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 08:14:00 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Feb 2 08:14:00 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 08:14:00 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Thu Feb 2 08:14:00 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 08:14:01 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Thu Feb 2 08:14:01 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 08:14:01 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 08:14:01 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Thu Feb 2 08:14:01 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 08:14:01 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Thu Feb 2 08:14:02 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0081.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 08:14:02 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Thu Feb 2 08:14:03 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 08:14:03 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Thu Feb 2 08:14:04 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0081.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Feb 2 12:03:02 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 12:03:02 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Feb 2 12:03:02 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Feb 2 12:03:02 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Feb 2 12:03:02 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 12:03:02 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Feb 2 12:03:02 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Thu Feb 2 12:03:03 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Feb 2 12:03:03 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 12:03:03 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Thu Feb 2 12:03:03 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 12:03:03 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Feb 2 12:03:03 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Thu Feb 2 12:03:03 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Thu Feb 2 12:03:03 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Feb 2 12:03:03 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 12:03:03 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Thu Feb 2 12:03:03 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 12:03:03 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Feb 2 12:03:03 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 12:03:03 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Feb 2 12:03:03 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Feb 2 12:03:03 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 12:03:03 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Thu Feb 2 12:03:04 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0082.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 12:03:04 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Thu Feb 2 12:03:04 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 12:03:04 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Thu Feb 2 12:03:04 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Feb 2 12:03:04 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 12:03:04 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Feb 2 12:03:05 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 12:03:05 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Feb 2 12:03:05 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 12:03:05 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Thu Feb 2 12:03:05 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 12:03:05 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Thu Feb 2 12:03:05 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 12:03:05 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 12:03:05 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Thu Feb 2 12:03:05 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 12:03:05 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Thu Feb 2 12:03:05 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0082.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 12:03:05 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Thu Feb 2 12:03:06 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 12:03:06 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Thu Feb 2 12:03:06 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0082.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Feb 2 16:01:20 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 16:01:20 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Feb 2 16:01:21 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Feb 2 16:01:21 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Feb 2 16:01:21 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 16:01:21 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Feb 2 16:01:21 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Thu Feb 2 16:01:21 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Feb 2 16:01:21 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 16:01:21 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Thu Feb 2 16:01:21 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 16:01:21 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Feb 2 16:01:21 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Thu Feb 2 16:01:21 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Thu Feb 2 16:01:21 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Feb 2 16:01:21 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 16:01:21 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Thu Feb 2 16:01:21 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 16:01:21 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Feb 2 16:01:21 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 16:01:21 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Feb 2 16:01:21 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Feb 2 16:01:21 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 16:01:21 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Thu Feb 2 16:01:21 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0083.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 16:01:21 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Thu Feb 2 16:01:21 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 16:01:21 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Thu Feb 2 16:01:21 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Feb 2 16:01:21 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 16:01:21 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Feb 2 16:01:21 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 16:01:21 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Feb 2 16:01:21 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 16:01:21 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Thu Feb 2 16:01:21 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 16:01:21 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Thu Feb 2 16:01:21 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 16:01:21 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 16:01:21 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Thu Feb 2 16:01:21 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 16:01:22 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Thu Feb 2 16:01:22 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0083.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 16:01:22 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Thu Feb 2 16:01:22 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 16:01:22 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Thu Feb 2 16:01:22 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0083.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Feb 2 20:01:09 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 20:01:09 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Feb 2 20:01:09 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Feb 2 20:01:09 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Feb 2 20:01:09 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 20:01:09 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Feb 2 20:01:09 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Thu Feb 2 20:01:09 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Feb 2 20:01:09 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 20:01:09 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Thu Feb 2 20:01:09 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 20:01:09 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Feb 2 20:01:09 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Thu Feb 2 20:01:09 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Thu Feb 2 20:01:09 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Feb 2 20:01:09 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 20:01:09 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Thu Feb 2 20:01:09 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 20:01:09 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Feb 2 20:01:09 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 20:01:09 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Feb 2 20:01:10 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Feb 2 20:01:10 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 20:01:10 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Thu Feb 2 20:01:10 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0084.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 20:01:10 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Thu Feb 2 20:01:10 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 20:01:10 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Thu Feb 2 20:01:10 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Feb 2 20:01:10 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 20:01:10 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Feb 2 20:01:10 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 20:01:10 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Feb 2 20:01:10 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 20:01:10 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Thu Feb 2 20:01:10 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 20:01:10 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Thu Feb 2 20:01:10 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 20:01:10 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 20:01:10 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Thu Feb 2 20:01:10 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 20:01:10 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Thu Feb 2 20:01:10 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0084.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 20:01:10 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Thu Feb 2 20:01:10 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 2 20:01:10 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Thu Feb 2 20:01:10 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0084.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Feb 3 08:12:58 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 08:12:59 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Feb 3 08:13:00 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Feb 3 08:13:01 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Feb 3 08:13:01 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 08:13:01 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Feb 3 08:13:01 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Fri Feb 3 08:13:01 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Feb 3 08:13:01 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 08:13:01 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Fri Feb 3 08:13:01 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 08:13:02 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Feb 3 08:13:02 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Fri Feb 3 08:13:02 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Fri Feb 3 08:13:02 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Feb 3 08:13:02 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 08:13:02 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Fri Feb 3 08:13:02 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 08:13:03 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Feb 3 08:13:03 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 08:13:03 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Feb 3 08:13:03 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Feb 3 08:13:03 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 08:13:03 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Fri Feb 3 08:13:11 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0085.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 08:13:11 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Fri Feb 3 08:13:11 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 08:13:11 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Fri Feb 3 08:13:11 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Feb 3 08:13:12 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 08:13:12 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Feb 3 08:13:12 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 08:13:12 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Feb 3 08:13:12 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 08:13:12 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Fri Feb 3 08:13:12 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 08:13:12 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Fri Feb 3 08:13:12 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 08:13:12 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 08:13:14 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Fri Feb 3 08:13:14 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 08:13:14 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Fri Feb 3 08:13:14 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0085.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 08:13:14 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Fri Feb 3 08:13:14 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 08:13:14 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Fri Feb 3 08:13:16 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0085.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Feb 3 12:02:56 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 12:02:56 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Feb 3 12:02:56 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Feb 3 12:02:56 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Feb 3 12:02:56 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 12:02:56 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Feb 3 12:02:56 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Fri Feb 3 12:02:57 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Feb 3 12:02:57 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 12:02:57 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Fri Feb 3 12:02:57 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 12:02:58 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Feb 3 12:02:58 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Fri Feb 3 12:02:58 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Fri Feb 3 12:02:58 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Feb 3 12:02:58 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 12:02:58 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Fri Feb 3 12:02:58 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 12:02:58 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Feb 3 12:02:58 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 12:02:58 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Feb 3 12:02:58 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Feb 3 12:02:58 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 12:02:58 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Fri Feb 3 12:02:59 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0086.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 12:02:59 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Fri Feb 3 12:02:59 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 12:02:59 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Fri Feb 3 12:02:59 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Feb 3 12:02:59 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 12:03:00 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Feb 3 12:03:00 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 12:03:00 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Feb 3 12:03:00 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 12:03:00 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Fri Feb 3 12:03:00 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 12:03:00 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Fri Feb 3 12:03:00 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 12:03:00 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 12:03:00 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Fri Feb 3 12:03:00 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 12:03:00 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Fri Feb 3 12:03:00 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0086.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 12:03:00 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Fri Feb 3 12:03:00 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 12:03:00 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Fri Feb 3 12:03:00 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0086.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Feb 3 16:01:12 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 16:01:12 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Feb 3 16:01:12 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Feb 3 16:01:12 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Feb 3 16:01:12 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 16:01:12 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Feb 3 16:01:12 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Fri Feb 3 16:01:12 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Feb 3 16:01:12 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 16:01:12 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Fri Feb 3 16:01:12 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 16:01:12 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Feb 3 16:01:12 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Fri Feb 3 16:01:12 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Fri Feb 3 16:01:12 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Feb 3 16:01:12 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 16:01:12 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Fri Feb 3 16:01:12 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 16:01:12 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Feb 3 16:01:12 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 16:01:12 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Feb 3 16:01:12 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Feb 3 16:01:12 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 16:01:12 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Fri Feb 3 16:01:12 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0087.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 16:01:12 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Fri Feb 3 16:01:12 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 16:01:13 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Fri Feb 3 16:01:13 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Feb 3 16:01:13 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 16:01:13 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Feb 3 16:01:13 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 16:01:13 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Feb 3 16:01:13 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 16:01:13 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Fri Feb 3 16:01:13 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 16:01:13 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Fri Feb 3 16:01:13 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 16:01:13 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 16:01:13 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Fri Feb 3 16:01:13 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 16:01:13 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Fri Feb 3 16:01:13 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0087.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 16:01:13 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Fri Feb 3 16:01:13 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 16:01:13 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Fri Feb 3 16:01:13 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0087.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Feb 3 20:01:16 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 20:01:16 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Feb 3 20:01:16 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Feb 3 20:01:16 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Feb 3 20:01:16 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 20:01:16 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Feb 3 20:01:16 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Fri Feb 3 20:01:16 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Feb 3 20:01:16 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 20:01:16 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Fri Feb 3 20:01:16 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 20:01:16 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Feb 3 20:01:16 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Fri Feb 3 20:01:16 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Fri Feb 3 20:01:16 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Feb 3 20:01:16 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 20:01:16 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Fri Feb 3 20:01:16 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 20:01:16 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Feb 3 20:01:16 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 20:01:16 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Feb 3 20:01:16 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Feb 3 20:01:16 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 20:01:16 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Fri Feb 3 20:01:16 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0088.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 20:01:16 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Fri Feb 3 20:01:16 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 20:01:16 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Fri Feb 3 20:01:16 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Feb 3 20:01:16 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 20:01:16 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Feb 3 20:01:16 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 20:01:16 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Feb 3 20:01:16 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 20:01:16 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Fri Feb 3 20:01:16 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 20:01:17 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Fri Feb 3 20:01:17 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 20:01:17 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 20:01:17 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Fri Feb 3 20:01:17 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 20:01:17 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Fri Feb 3 20:01:17 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0088.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 20:01:17 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Fri Feb 3 20:01:17 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 3 20:01:17 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Fri Feb 3 20:01:17 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0088.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Feb 4 08:08:36 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 08:08:36 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Feb 4 08:08:36 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Feb 4 08:08:36 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Feb 4 08:08:36 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 08:08:36 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Feb 4 08:08:36 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sat Feb 4 08:08:36 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Feb 4 08:08:37 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 08:08:37 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Sat Feb 4 08:08:37 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 08:08:37 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Feb 4 08:08:38 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sat Feb 4 08:08:38 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Sat Feb 4 08:08:38 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Feb 4 08:08:38 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 08:08:38 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Sat Feb 4 08:08:38 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 08:08:38 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Feb 4 08:08:38 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 08:08:39 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Feb 4 08:08:39 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Feb 4 08:08:39 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 08:08:39 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Sat Feb 4 08:08:42 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0089.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 08:08:42 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Sat Feb 4 08:08:42 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 08:08:42 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Sat Feb 4 08:08:42 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Feb 4 08:08:42 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 08:08:42 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Feb 4 08:08:42 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 08:08:43 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Feb 4 08:08:43 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 08:08:43 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Sat Feb 4 08:08:43 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 08:08:43 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Sat Feb 4 08:08:43 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 08:08:43 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 08:08:43 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Sat Feb 4 08:08:43 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 08:08:43 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sat Feb 4 08:08:44 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0089.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 08:08:44 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Sat Feb 4 08:08:44 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 08:08:44 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sat Feb 4 08:08:46 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0089.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Feb 4 12:02:55 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 12:02:55 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Feb 4 12:02:55 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Feb 4 12:02:55 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Feb 4 12:02:55 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 12:02:55 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Feb 4 12:02:55 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sat Feb 4 12:02:55 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Feb 4 12:02:55 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 12:02:55 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Sat Feb 4 12:02:55 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 12:02:55 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Feb 4 12:02:55 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sat Feb 4 12:02:55 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Sat Feb 4 12:02:55 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Feb 4 12:02:55 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 12:02:55 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Sat Feb 4 12:02:55 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 12:02:55 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Feb 4 12:02:55 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 12:02:55 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Feb 4 12:02:55 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Feb 4 12:02:55 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 12:02:55 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Sat Feb 4 12:02:57 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0090.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 12:02:57 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Sat Feb 4 12:02:57 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 12:02:58 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Sat Feb 4 12:02:58 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Feb 4 12:02:58 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 12:02:58 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Feb 4 12:02:58 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 12:02:58 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Feb 4 12:02:58 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 12:02:58 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Sat Feb 4 12:02:58 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 12:02:58 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Sat Feb 4 12:02:59 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 12:02:59 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 12:02:59 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Sat Feb 4 12:02:59 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 12:02:59 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sat Feb 4 12:02:59 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0090.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 12:02:59 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Sat Feb 4 12:02:59 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 12:02:59 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sat Feb 4 12:02:59 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0090.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Feb 4 16:01:21 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 16:01:21 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Feb 4 16:01:21 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Feb 4 16:01:21 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Feb 4 16:01:21 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 16:01:21 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Feb 4 16:01:21 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sat Feb 4 16:01:21 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Feb 4 16:01:21 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 16:01:21 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Sat Feb 4 16:01:21 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 16:01:21 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Feb 4 16:01:21 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sat Feb 4 16:01:21 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Sat Feb 4 16:01:21 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Feb 4 16:01:21 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 16:01:21 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Sat Feb 4 16:01:21 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 16:01:21 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Feb 4 16:01:21 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 16:01:21 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Feb 4 16:01:21 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Feb 4 16:01:21 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 16:01:22 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Sat Feb 4 16:01:22 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0091.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 16:01:22 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Sat Feb 4 16:01:22 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 16:01:22 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Sat Feb 4 16:01:22 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Feb 4 16:01:22 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 16:01:22 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Feb 4 16:01:22 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 16:01:22 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Feb 4 16:01:22 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 16:01:22 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Sat Feb 4 16:01:22 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 16:01:22 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Sat Feb 4 16:01:22 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 16:01:22 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 16:01:22 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Sat Feb 4 16:01:22 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 16:01:22 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sat Feb 4 16:01:22 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0091.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 16:01:22 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Sat Feb 4 16:01:22 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 16:01:22 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sat Feb 4 16:01:22 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0091.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Feb 4 20:01:13 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 20:01:13 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Feb 4 20:01:13 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Feb 4 20:01:13 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Feb 4 20:01:14 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 20:01:14 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Feb 4 20:01:14 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sat Feb 4 20:01:14 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Feb 4 20:01:14 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 20:01:14 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Sat Feb 4 20:01:14 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 20:01:14 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Feb 4 20:01:14 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sat Feb 4 20:01:14 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Sat Feb 4 20:01:14 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Feb 4 20:01:14 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 20:01:14 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Sat Feb 4 20:01:14 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 20:01:14 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Feb 4 20:01:14 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 20:01:14 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Feb 4 20:01:14 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Feb 4 20:01:14 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 20:01:14 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Sat Feb 4 20:01:14 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0092.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 20:01:14 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Sat Feb 4 20:01:14 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 20:01:14 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Sat Feb 4 20:01:14 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Feb 4 20:01:14 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 20:01:14 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Feb 4 20:01:14 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 20:01:14 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Feb 4 20:01:14 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 20:01:14 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Sat Feb 4 20:01:14 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 20:01:14 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Sat Feb 4 20:01:14 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 20:01:14 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 20:01:14 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Sat Feb 4 20:01:14 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 20:01:14 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sat Feb 4 20:01:14 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0092.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 20:01:14 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Sat Feb 4 20:01:14 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 4 20:01:14 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sat Feb 4 20:01:14 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0092.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Feb 5 08:08:08 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 08:08:10 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Feb 5 08:08:10 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Feb 5 08:08:10 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Feb 5 08:08:10 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 08:08:10 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Feb 5 08:08:10 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sun Feb 5 08:08:10 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Feb 5 08:08:10 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 08:08:10 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Sun Feb 5 08:08:10 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 08:08:10 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Feb 5 08:08:10 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sun Feb 5 08:08:10 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Sun Feb 5 08:08:11 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Feb 5 08:08:11 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 08:08:11 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Sun Feb 5 08:08:11 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 08:08:11 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Feb 5 08:08:11 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 08:08:11 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Feb 5 08:08:11 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Feb 5 08:08:11 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 08:08:11 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Sun Feb 5 08:08:12 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0093.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 08:08:12 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Sun Feb 5 08:08:12 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 08:08:12 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Sun Feb 5 08:08:12 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Feb 5 08:08:12 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 08:08:12 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Feb 5 08:08:12 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 08:08:12 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Feb 5 08:08:13 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 08:08:13 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Sun Feb 5 08:08:13 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 08:08:13 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Sun Feb 5 08:08:13 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 08:08:13 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 08:08:13 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Sun Feb 5 08:08:13 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 08:08:13 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sun Feb 5 08:08:13 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0093.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 08:08:13 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Sun Feb 5 08:08:13 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 08:08:13 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sun Feb 5 08:08:13 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0093.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Feb 5 12:02:57 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 12:02:57 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Feb 5 12:02:57 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Feb 5 12:02:57 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Feb 5 12:02:57 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 12:02:57 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Feb 5 12:02:57 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sun Feb 5 12:02:57 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Feb 5 12:02:57 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 12:02:57 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Sun Feb 5 12:02:57 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 12:02:57 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Feb 5 12:02:57 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sun Feb 5 12:02:57 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Sun Feb 5 12:02:57 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Feb 5 12:02:57 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 12:02:57 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Sun Feb 5 12:02:57 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 12:02:57 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Feb 5 12:02:57 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 12:02:57 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Feb 5 12:02:57 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Feb 5 12:02:57 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 12:02:57 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Sun Feb 5 12:02:58 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0094.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 12:02:59 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Sun Feb 5 12:02:59 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 12:02:59 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Sun Feb 5 12:02:59 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Feb 5 12:02:59 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 12:02:59 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Feb 5 12:02:59 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 12:02:59 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Feb 5 12:02:59 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 12:02:59 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Sun Feb 5 12:02:59 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 12:02:59 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Sun Feb 5 12:02:59 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 12:02:59 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 12:02:59 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Sun Feb 5 12:02:59 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 12:02:59 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sun Feb 5 12:02:59 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0094.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 12:02:59 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Sun Feb 5 12:02:59 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 12:02:59 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sun Feb 5 12:02:59 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0094.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0095.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0095.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sun Feb 5 16:01:18 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0095.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Feb 5 20:01:07 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 20:01:07 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Feb 5 20:01:07 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Feb 5 20:01:07 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Feb 5 20:01:07 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 20:01:07 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Feb 5 20:01:07 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sun Feb 5 20:01:07 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Feb 5 20:01:07 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 20:01:07 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Sun Feb 5 20:01:07 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 20:01:07 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Feb 5 20:01:07 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sun Feb 5 20:01:07 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Sun Feb 5 20:01:07 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Feb 5 20:01:07 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 20:01:07 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Sun Feb 5 20:01:07 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 20:01:07 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Feb 5 20:01:07 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 20:01:07 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Feb 5 20:01:07 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Feb 5 20:01:07 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 20:01:07 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Sun Feb 5 20:01:07 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0096.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 20:01:07 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Sun Feb 5 20:01:07 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 20:01:07 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Sun Feb 5 20:01:07 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Feb 5 20:01:07 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 20:01:07 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Feb 5 20:01:07 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 20:01:07 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Feb 5 20:01:07 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 20:01:07 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Sun Feb 5 20:01:07 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 20:01:08 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Sun Feb 5 20:01:08 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 20:01:08 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 20:01:08 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Sun Feb 5 20:01:08 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 20:01:08 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sun Feb 5 20:01:08 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0096.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 20:01:08 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Sun Feb 5 20:01:08 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 5 20:01:08 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sun Feb 5 20:01:08 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0096.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Feb 6 08:16:08 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 08:16:10 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Feb 6 08:16:10 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Feb 6 08:16:10 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Feb 6 08:16:10 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 08:16:11 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Feb 6 08:16:11 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Mon Feb 6 08:16:11 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Feb 6 08:16:11 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 08:16:11 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Mon Feb 6 08:16:11 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 08:16:11 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Feb 6 08:16:11 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Mon Feb 6 08:16:13 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Mon Feb 6 08:16:13 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Feb 6 08:16:13 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 08:16:13 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Mon Feb 6 08:16:14 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 08:16:14 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Feb 6 08:16:14 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 08:16:14 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Feb 6 08:16:15 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Feb 6 08:16:15 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 08:16:15 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Mon Feb 6 08:16:19 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0097.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 08:16:19 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Mon Feb 6 08:16:19 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 08:16:20 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Mon Feb 6 08:16:20 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Feb 6 08:16:20 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 08:16:20 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Feb 6 08:16:20 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 08:16:20 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Feb 6 08:16:20 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 08:16:21 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Mon Feb 6 08:16:21 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 08:16:21 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Mon Feb 6 08:16:21 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 08:16:21 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 08:16:21 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Mon Feb 6 08:16:22 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 08:16:22 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Mon Feb 6 08:16:23 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0097.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 08:16:23 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Mon Feb 6 08:16:24 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 08:16:24 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Mon Feb 6 08:16:26 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0097.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Feb 6 12:02:57 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 12:02:57 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Feb 6 12:02:57 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Feb 6 12:02:57 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Feb 6 12:02:57 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 12:02:57 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Feb 6 12:02:57 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Mon Feb 6 12:02:58 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Feb 6 12:02:58 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 12:02:58 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Mon Feb 6 12:02:58 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 12:02:58 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Feb 6 12:02:58 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Mon Feb 6 12:02:58 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Mon Feb 6 12:02:58 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Feb 6 12:02:58 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 12:02:58 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Mon Feb 6 12:02:58 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 12:02:58 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Feb 6 12:02:59 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 12:02:59 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Feb 6 12:02:59 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Feb 6 12:02:59 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 12:02:59 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Mon Feb 6 12:03:01 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0098.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 12:03:01 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Mon Feb 6 12:03:02 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 12:03:02 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Mon Feb 6 12:03:02 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Feb 6 12:03:02 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 12:03:02 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Feb 6 12:03:03 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 12:03:03 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Feb 6 12:03:03 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 12:03:03 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Mon Feb 6 12:03:03 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 12:03:03 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Mon Feb 6 12:03:03 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 12:03:03 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 12:03:03 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Mon Feb 6 12:03:03 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 12:03:03 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Mon Feb 6 12:03:05 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0098.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 12:03:05 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Mon Feb 6 12:03:05 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 12:03:05 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Mon Feb 6 12:03:05 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0098.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Feb 6 16:01:15 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 16:01:15 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Feb 6 16:01:15 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Feb 6 16:01:15 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Feb 6 16:01:15 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 16:01:15 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Feb 6 16:01:15 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Mon Feb 6 16:01:15 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Feb 6 16:01:15 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 16:01:15 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Mon Feb 6 16:01:15 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 16:01:15 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Feb 6 16:01:15 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Mon Feb 6 16:01:15 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Mon Feb 6 16:01:15 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Feb 6 16:01:15 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 16:01:15 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Mon Feb 6 16:01:16 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 16:01:16 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Feb 6 16:01:16 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 16:01:16 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Feb 6 16:01:16 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Feb 6 16:01:16 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 16:01:16 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Mon Feb 6 16:01:16 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0099.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 16:01:16 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Mon Feb 6 16:01:16 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 16:01:16 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Mon Feb 6 16:01:16 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Feb 6 16:01:16 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 16:01:16 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Feb 6 16:01:16 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 16:01:16 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Feb 6 16:01:16 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 16:01:16 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Mon Feb 6 16:01:16 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 16:01:16 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Mon Feb 6 16:01:16 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 16:01:16 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 16:01:16 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Mon Feb 6 16:01:16 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 16:01:16 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Mon Feb 6 16:01:16 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0099.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 16:01:16 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Mon Feb 6 16:01:16 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 16:01:16 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Mon Feb 6 16:01:16 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0099.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Feb 6 20:01:07 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 20:01:07 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Feb 6 20:01:07 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Feb 6 20:01:07 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Feb 6 20:01:07 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 20:01:07 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Feb 6 20:01:07 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Mon Feb 6 20:01:07 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Feb 6 20:01:07 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 20:01:07 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Mon Feb 6 20:01:07 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 20:01:07 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Feb 6 20:01:07 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Mon Feb 6 20:01:08 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Mon Feb 6 20:01:08 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Feb 6 20:01:08 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 20:01:08 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Mon Feb 6 20:01:08 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 20:01:08 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Feb 6 20:01:08 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 20:01:08 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Feb 6 20:01:08 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Feb 6 20:01:08 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 20:01:08 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Mon Feb 6 20:01:08 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0100.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 20:01:08 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Mon Feb 6 20:01:08 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 20:01:08 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Mon Feb 6 20:01:08 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Feb 6 20:01:08 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 20:01:08 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Feb 6 20:01:08 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 20:01:08 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Feb 6 20:01:08 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 20:01:08 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Mon Feb 6 20:01:08 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 20:01:08 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Mon Feb 6 20:01:08 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 20:01:08 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 20:01:08 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Mon Feb 6 20:01:08 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 20:01:08 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Mon Feb 6 20:01:08 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0100.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 20:01:08 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Mon Feb 6 20:01:08 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 6 20:01:08 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Mon Feb 6 20:01:08 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0100.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Feb 7 08:25:41 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 08:25:41 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Feb 7 08:25:41 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Feb 7 08:25:42 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Feb 7 08:25:42 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 08:25:42 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Feb 7 08:25:42 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Tue Feb 7 08:25:42 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Feb 7 08:25:42 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 08:25:42 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Tue Feb 7 08:25:42 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 08:25:43 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Feb 7 08:25:43 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Tue Feb 7 08:25:44 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Tue Feb 7 08:25:44 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Feb 7 08:25:44 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 08:25:44 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Tue Feb 7 08:25:45 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 08:25:45 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Feb 7 08:25:45 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 08:25:45 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Feb 7 08:25:45 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Feb 7 08:25:45 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 08:25:45 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Tue Feb 7 08:25:52 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0101.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 08:25:52 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Tue Feb 7 08:25:53 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 08:25:53 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Tue Feb 7 08:25:53 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Feb 7 08:25:53 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 08:25:53 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Feb 7 08:25:53 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 08:25:53 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Feb 7 08:25:53 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 08:25:53 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Tue Feb 7 08:25:53 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 08:25:53 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Tue Feb 7 08:25:54 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 08:25:54 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 08:25:54 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Tue Feb 7 08:25:54 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 08:25:54 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Tue Feb 7 08:25:55 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0101.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 08:25:55 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Tue Feb 7 08:25:55 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 08:25:55 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Tue Feb 7 08:25:58 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0101.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Feb 7 12:03:35 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 12:03:35 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Feb 7 12:03:35 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Feb 7 12:03:35 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Feb 7 12:03:35 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 12:03:35 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Feb 7 12:03:35 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Tue Feb 7 12:03:35 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Feb 7 12:03:35 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 12:03:35 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Tue Feb 7 12:03:35 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 12:03:35 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Feb 7 12:03:35 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Tue Feb 7 12:03:35 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Tue Feb 7 12:03:35 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Feb 7 12:03:35 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 12:03:35 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Tue Feb 7 12:03:35 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 12:03:35 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Feb 7 12:03:35 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 12:03:35 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Feb 7 12:03:35 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Feb 7 12:03:35 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 12:03:35 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Tue Feb 7 12:03:37 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0102.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 12:03:37 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Tue Feb 7 12:03:37 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 12:03:37 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Tue Feb 7 12:03:37 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Feb 7 12:03:37 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 12:03:37 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Feb 7 12:03:38 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 12:03:38 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Feb 7 12:03:38 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 12:03:38 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Tue Feb 7 12:03:38 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 12:03:38 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Tue Feb 7 12:03:38 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 12:03:38 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 12:03:38 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Tue Feb 7 12:03:38 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 12:03:38 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Tue Feb 7 12:03:39 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0102.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 12:03:39 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Tue Feb 7 12:03:39 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 12:03:39 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Tue Feb 7 12:03:39 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0102.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Feb 7 16:01:16 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 16:01:16 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Feb 7 16:01:16 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Feb 7 16:01:16 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Feb 7 16:01:16 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 16:01:16 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Feb 7 16:01:17 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Tue Feb 7 16:01:17 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Feb 7 16:01:17 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 16:01:17 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Tue Feb 7 16:01:17 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 16:01:17 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Feb 7 16:01:17 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Tue Feb 7 16:01:19 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Tue Feb 7 16:01:22 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Feb 7 16:01:22 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 16:01:22 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Tue Feb 7 16:01:22 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 16:01:22 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Feb 7 16:01:22 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 16:01:22 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Feb 7 16:01:22 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Feb 7 16:01:23 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 16:01:23 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Tue Feb 7 16:01:24 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0103.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 16:01:24 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Tue Feb 7 16:01:25 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 16:01:25 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Tue Feb 7 16:01:25 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Feb 7 16:01:25 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 16:01:25 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Feb 7 16:01:25 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 16:01:25 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Feb 7 16:01:25 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 16:01:25 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Tue Feb 7 16:01:25 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 16:01:25 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Tue Feb 7 16:01:25 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 16:01:25 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 16:01:25 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Tue Feb 7 16:01:25 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 16:01:25 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Tue Feb 7 16:01:26 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0103.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 16:01:26 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Tue Feb 7 16:01:26 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 16:01:26 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Tue Feb 7 16:01:26 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0103.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Feb 7 20:01:16 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 20:01:16 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Feb 7 20:01:16 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Feb 7 20:01:16 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Feb 7 20:01:16 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 20:01:16 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Feb 7 20:01:16 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Tue Feb 7 20:01:16 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Feb 7 20:01:16 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 20:01:16 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Tue Feb 7 20:01:16 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 20:01:16 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Feb 7 20:01:16 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Tue Feb 7 20:01:16 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Tue Feb 7 20:01:16 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Feb 7 20:01:16 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 20:01:16 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Tue Feb 7 20:01:16 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 20:01:16 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Feb 7 20:01:16 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 20:01:17 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Feb 7 20:01:17 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Feb 7 20:01:17 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 20:01:17 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Tue Feb 7 20:01:17 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0104.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 20:01:17 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Tue Feb 7 20:01:17 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 20:01:17 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Tue Feb 7 20:01:17 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Feb 7 20:01:17 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 20:01:17 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Feb 7 20:01:17 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 20:01:17 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Feb 7 20:01:17 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 20:01:17 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Tue Feb 7 20:01:17 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 20:01:17 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Tue Feb 7 20:01:17 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 20:01:17 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 20:01:17 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Tue Feb 7 20:01:17 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 20:01:17 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Tue Feb 7 20:01:17 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0104.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 20:01:17 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Tue Feb 7 20:01:17 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 7 20:01:17 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Tue Feb 7 20:01:17 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0104.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Feb 8 08:24:14 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 08:24:15 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Feb 8 08:24:15 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Feb 8 08:24:15 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 8 08:24:16 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 08:24:16 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 8 08:24:16 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Wed Feb 8 08:24:16 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Feb 8 08:24:17 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 08:24:17 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Wed Feb 8 08:24:17 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 08:24:17 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Feb 8 08:24:18 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Wed Feb 8 08:24:18 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Wed Feb 8 08:24:19 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Feb 8 08:24:19 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 08:24:19 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Wed Feb 8 08:24:19 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 08:24:20 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 8 08:24:21 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 08:24:21 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 8 08:24:21 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 8 08:24:21 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 08:24:22 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Wed Feb 8 08:24:33 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0105.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 08:24:34 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Wed Feb 8 08:24:34 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 08:24:34 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Wed Feb 8 08:24:35 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Feb 8 08:24:35 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 08:24:35 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Feb 8 08:24:35 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 08:24:36 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Feb 8 08:24:36 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 08:24:37 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Wed Feb 8 08:24:37 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 08:24:37 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Wed Feb 8 08:24:37 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 08:24:39 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 08:24:40 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Wed Feb 8 08:24:40 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 08:24:41 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Wed Feb 8 08:24:46 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0105.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 08:24:46 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Wed Feb 8 08:24:46 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 08:24:47 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Wed Feb 8 08:24:49 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0105.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Feb 8 12:03:37 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 12:03:37 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Feb 8 12:03:37 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Feb 8 12:03:37 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 8 12:03:37 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 12:03:37 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 8 12:03:37 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Wed Feb 8 12:03:37 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Feb 8 12:03:37 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 12:03:37 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Wed Feb 8 12:03:37 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 12:03:37 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Feb 8 12:03:37 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Wed Feb 8 12:03:37 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Wed Feb 8 12:03:37 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Feb 8 12:03:37 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 12:03:37 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Wed Feb 8 12:03:37 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 12:03:38 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 8 12:03:38 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 12:03:38 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 8 12:03:38 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 8 12:03:38 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 12:03:38 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Wed Feb 8 12:03:45 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0106.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 12:03:45 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Wed Feb 8 12:03:46 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 12:03:46 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Wed Feb 8 12:03:46 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Feb 8 12:03:46 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 12:03:46 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Feb 8 12:03:46 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 12:03:46 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Feb 8 12:03:47 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 12:03:47 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Wed Feb 8 12:03:47 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 12:03:47 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Wed Feb 8 12:03:48 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 12:03:48 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 12:03:48 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Wed Feb 8 12:03:48 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 12:03:48 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Wed Feb 8 12:03:49 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0106.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 12:03:49 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Wed Feb 8 12:03:49 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 12:03:50 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Wed Feb 8 12:03:50 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0106.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Feb 8 16:01:27 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 16:01:27 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Feb 8 16:01:28 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Feb 8 16:01:28 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 8 16:01:28 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 16:01:28 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 8 16:01:28 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Wed Feb 8 16:01:28 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Feb 8 16:01:28 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 16:01:28 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Wed Feb 8 16:01:28 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 16:01:28 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Feb 8 16:01:28 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Wed Feb 8 16:01:28 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Wed Feb 8 16:01:28 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Feb 8 16:01:28 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 16:01:28 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Wed Feb 8 16:01:28 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 16:01:28 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 8 16:01:28 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 16:01:28 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 8 16:01:28 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 8 16:01:28 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 16:01:28 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Wed Feb 8 16:01:28 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0107.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 16:01:28 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Wed Feb 8 16:01:28 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 16:01:28 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Wed Feb 8 16:01:28 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Feb 8 16:01:28 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 16:01:28 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Feb 8 16:01:28 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 16:01:28 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Feb 8 16:01:28 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 16:01:28 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Wed Feb 8 16:01:28 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 16:01:28 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Wed Feb 8 16:01:28 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 16:01:28 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 16:01:28 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Wed Feb 8 16:01:28 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 16:01:28 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Wed Feb 8 16:01:28 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0107.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 16:01:28 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Wed Feb 8 16:01:28 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 16:01:29 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Wed Feb 8 16:01:29 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0107.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Feb 8 20:01:12 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 20:01:12 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Feb 8 20:01:12 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Feb 8 20:01:12 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 8 20:01:12 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 20:01:12 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 8 20:01:12 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Wed Feb 8 20:01:12 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Feb 8 20:01:12 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 20:01:12 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Wed Feb 8 20:01:12 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 20:01:12 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Feb 8 20:01:12 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Wed Feb 8 20:01:12 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Wed Feb 8 20:01:12 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Feb 8 20:01:12 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 20:01:12 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Wed Feb 8 20:01:12 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 20:01:12 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 8 20:01:12 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 20:01:12 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 8 20:01:12 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 8 20:01:12 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 20:01:12 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Wed Feb 8 20:01:12 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0108.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 20:01:12 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Wed Feb 8 20:01:12 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 20:01:12 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Wed Feb 8 20:01:15 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Feb 8 20:01:15 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 20:01:15 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Feb 8 20:01:15 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 20:01:15 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Feb 8 20:01:15 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 20:01:15 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Wed Feb 8 20:01:15 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 20:01:15 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Wed Feb 8 20:01:15 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 20:01:15 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 20:01:15 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Wed Feb 8 20:01:15 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 20:01:15 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Wed Feb 8 20:01:15 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0108.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 20:01:15 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Wed Feb 8 20:01:15 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 8 20:01:15 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Wed Feb 8 20:01:15 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0108.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Feb 9 08:10:04 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 08:10:04 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Feb 9 08:10:04 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Feb 9 08:10:05 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Feb 9 08:10:05 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 08:10:05 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Feb 9 08:10:05 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Thu Feb 9 08:10:06 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Feb 9 08:10:06 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 08:10:07 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Thu Feb 9 08:10:07 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 08:10:07 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Feb 9 08:10:07 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Thu Feb 9 08:10:07 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Thu Feb 9 08:10:07 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Feb 9 08:10:07 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 08:10:08 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Thu Feb 9 08:10:08 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 08:10:08 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Feb 9 08:10:08 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 08:10:08 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Feb 9 08:10:08 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Feb 9 08:10:08 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 08:10:08 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Thu Feb 9 08:10:11 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0109.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 08:10:11 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Thu Feb 9 08:10:12 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 08:10:12 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Thu Feb 9 08:10:12 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Feb 9 08:10:12 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 08:10:12 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Feb 9 08:10:12 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 08:10:12 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Feb 9 08:10:12 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 08:10:12 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Thu Feb 9 08:10:12 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 08:10:12 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Thu Feb 9 08:10:12 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 08:10:13 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 08:10:13 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Thu Feb 9 08:10:13 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 08:10:13 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Thu Feb 9 08:10:13 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0109.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 08:10:13 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Thu Feb 9 08:10:13 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 08:10:13 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Thu Feb 9 08:10:13 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0109.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Feb 9 12:03:29 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 12:03:29 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Feb 9 12:03:29 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Feb 9 12:03:29 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Feb 9 12:03:29 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 12:03:29 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Feb 9 12:03:29 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Thu Feb 9 12:03:29 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Feb 9 12:03:29 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 12:03:29 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Thu Feb 9 12:03:29 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 12:03:29 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Feb 9 12:03:29 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Thu Feb 9 12:03:29 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Thu Feb 9 12:03:29 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Feb 9 12:03:29 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 12:03:29 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Thu Feb 9 12:03:29 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 12:03:29 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Feb 9 12:03:29 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 12:03:29 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Feb 9 12:03:29 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Feb 9 12:03:29 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 12:03:29 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Thu Feb 9 12:03:31 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0110.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 12:03:31 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Thu Feb 9 12:03:31 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 12:03:32 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Thu Feb 9 12:03:32 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Feb 9 12:03:32 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 12:03:32 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Feb 9 12:03:32 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 12:03:33 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Feb 9 12:03:33 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 12:03:33 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Thu Feb 9 12:03:33 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 12:03:33 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Thu Feb 9 12:03:33 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 12:03:33 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 12:03:33 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Thu Feb 9 12:03:33 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 12:03:33 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Thu Feb 9 12:03:33 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0110.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 12:03:33 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Thu Feb 9 12:03:33 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 12:03:33 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Thu Feb 9 12:03:33 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0110.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Feb 9 16:01:25 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 16:01:28 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Feb 9 16:01:28 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Feb 9 16:01:28 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Feb 9 16:01:28 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 16:01:28 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Feb 9 16:01:28 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Thu Feb 9 16:01:28 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Feb 9 16:01:28 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 16:01:28 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Thu Feb 9 16:01:28 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 16:01:28 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Feb 9 16:01:28 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Thu Feb 9 16:01:28 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Thu Feb 9 16:01:28 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Feb 9 16:01:28 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 16:01:28 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Thu Feb 9 16:01:28 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 16:01:28 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Feb 9 16:01:28 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 16:01:28 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Feb 9 16:01:28 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Feb 9 16:01:28 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 16:01:28 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Thu Feb 9 16:01:29 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0111.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 16:01:29 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Thu Feb 9 16:01:29 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 16:01:29 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Thu Feb 9 16:01:29 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Feb 9 16:01:29 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 16:01:29 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Feb 9 16:01:29 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 16:01:29 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Feb 9 16:01:29 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 16:01:29 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Thu Feb 9 16:01:29 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 16:01:29 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Thu Feb 9 16:01:29 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 16:01:29 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 16:01:29 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Thu Feb 9 16:01:29 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 16:01:29 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Thu Feb 9 16:01:29 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0111.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 16:01:29 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Thu Feb 9 16:01:29 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 16:01:29 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Thu Feb 9 16:01:29 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0111.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Feb 9 20:01:23 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 20:01:23 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Feb 9 20:01:23 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Feb 9 20:01:23 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Feb 9 20:01:23 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 20:01:23 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Feb 9 20:01:23 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Thu Feb 9 20:01:23 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Feb 9 20:01:23 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 20:01:23 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Thu Feb 9 20:01:23 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 20:01:23 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Feb 9 20:01:23 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Thu Feb 9 20:01:23 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Thu Feb 9 20:01:23 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Feb 9 20:01:23 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 20:01:23 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Thu Feb 9 20:01:23 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 20:01:23 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Feb 9 20:01:23 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 20:01:23 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Feb 9 20:01:23 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Feb 9 20:01:23 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 20:01:23 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Thu Feb 9 20:01:23 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0112.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 20:01:23 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Thu Feb 9 20:01:23 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 20:01:23 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Thu Feb 9 20:01:23 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Feb 9 20:01:23 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 20:01:23 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Feb 9 20:01:23 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 20:01:23 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Feb 9 20:01:23 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 20:01:24 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Thu Feb 9 20:01:24 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 20:01:24 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Thu Feb 9 20:01:24 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 20:01:24 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 20:01:24 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Thu Feb 9 20:01:24 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 20:01:24 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Thu Feb 9 20:01:24 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0112.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 20:01:24 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Thu Feb 9 20:01:24 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 9 20:01:24 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Thu Feb 9 20:01:24 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0112.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Feb 10 08:21:59 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 08:22:10 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Feb 10 08:22:10 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Feb 10 08:22:11 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Feb 10 08:22:11 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 08:22:11 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Feb 10 08:22:11 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Fri Feb 10 08:22:13 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Feb 10 08:22:13 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 08:22:15 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Fri Feb 10 08:22:15 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 08:22:15 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Feb 10 08:22:15 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Fri Feb 10 08:22:15 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Fri Feb 10 08:22:15 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Feb 10 08:22:16 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 08:22:16 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Fri Feb 10 08:22:17 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 08:22:19 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Feb 10 08:22:20 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 08:22:20 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Feb 10 08:22:21 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Feb 10 08:22:21 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 08:22:22 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Fri Feb 10 08:22:46 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0113.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 08:22:46 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Fri Feb 10 08:22:47 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 08:22:48 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Fri Feb 10 08:22:48 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Feb 10 08:22:48 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 08:22:49 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Feb 10 08:22:49 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 08:22:50 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Feb 10 08:22:50 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 08:22:51 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Fri Feb 10 08:22:51 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 08:22:52 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Fri Feb 10 08:22:52 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 08:22:53 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 08:22:54 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Fri Feb 10 08:22:55 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 08:22:55 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Fri Feb 10 08:22:57 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0113.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 08:22:57 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Fri Feb 10 08:22:57 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 08:22:58 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Fri Feb 10 08:23:04 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0113.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Feb 10 12:03:50 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 12:03:51 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Feb 10 12:03:51 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Feb 10 12:03:51 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Feb 10 12:03:51 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 12:03:51 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Feb 10 12:03:51 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Fri Feb 10 12:03:51 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Feb 10 12:03:51 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 12:03:51 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Fri Feb 10 12:03:51 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 12:03:51 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Feb 10 12:03:51 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Fri Feb 10 12:03:51 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Fri Feb 10 12:03:51 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Feb 10 12:03:51 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 12:03:51 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Fri Feb 10 12:03:53 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 12:03:53 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Feb 10 12:03:53 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 12:03:53 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Feb 10 12:03:53 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Feb 10 12:03:53 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 12:03:53 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Fri Feb 10 12:03:54 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0114.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 12:03:54 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Fri Feb 10 12:03:54 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 12:03:54 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Fri Feb 10 12:03:54 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Feb 10 12:03:54 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 12:03:55 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Feb 10 12:03:55 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 12:03:55 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Feb 10 12:03:55 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 12:03:55 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Fri Feb 10 12:03:55 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 12:03:55 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Fri Feb 10 12:03:55 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 12:03:55 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 12:03:55 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Fri Feb 10 12:03:55 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 12:03:55 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Fri Feb 10 12:03:55 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0114.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 12:03:55 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Fri Feb 10 12:03:55 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 12:03:55 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Fri Feb 10 12:03:55 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0114.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Feb 10 16:01:18 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 16:01:18 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Feb 10 16:01:18 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Feb 10 16:01:18 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Feb 10 16:01:18 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 16:01:18 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Feb 10 16:01:18 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Fri Feb 10 16:01:18 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Feb 10 16:01:18 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 16:01:18 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Fri Feb 10 16:01:18 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 16:01:18 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Feb 10 16:01:18 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Fri Feb 10 16:01:18 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Fri Feb 10 16:01:18 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Feb 10 16:01:18 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 16:01:18 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Fri Feb 10 16:01:18 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 16:01:18 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Feb 10 16:01:18 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 16:01:18 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Feb 10 16:01:18 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Feb 10 16:01:18 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 16:01:18 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Fri Feb 10 16:01:18 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0115.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 16:01:18 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Fri Feb 10 16:01:18 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 16:01:18 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Fri Feb 10 16:01:18 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Feb 10 16:01:18 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 16:01:18 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Feb 10 16:01:18 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 16:01:18 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Feb 10 16:01:19 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 16:01:19 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Fri Feb 10 16:01:19 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 16:01:19 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Fri Feb 10 16:01:19 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 16:01:19 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 16:01:19 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Fri Feb 10 16:01:19 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 16:01:19 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Fri Feb 10 16:01:19 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0115.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 16:01:19 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Fri Feb 10 16:01:19 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 16:01:19 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Fri Feb 10 16:01:19 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0115.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Feb 10 20:01:20 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 20:01:20 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Feb 10 20:01:20 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Feb 10 20:01:20 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Feb 10 20:01:20 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 20:01:20 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Feb 10 20:01:20 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Fri Feb 10 20:01:20 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Feb 10 20:01:20 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 20:01:20 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Fri Feb 10 20:01:20 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 20:01:20 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Feb 10 20:01:20 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Fri Feb 10 20:01:20 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Fri Feb 10 20:01:20 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Feb 10 20:01:20 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 20:01:20 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Fri Feb 10 20:01:20 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 20:01:20 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Feb 10 20:01:20 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 20:01:20 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Feb 10 20:01:20 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Feb 10 20:01:20 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 20:01:20 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Fri Feb 10 20:01:20 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0116.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 20:01:20 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Fri Feb 10 20:01:20 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 20:01:20 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Fri Feb 10 20:01:20 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Feb 10 20:01:20 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 20:01:20 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Feb 10 20:01:20 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 20:01:20 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Feb 10 20:01:21 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 20:01:21 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Fri Feb 10 20:01:21 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 20:01:21 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Fri Feb 10 20:01:21 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 20:01:21 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 20:01:21 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Fri Feb 10 20:01:21 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 20:01:22 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Fri Feb 10 20:01:22 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0116.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 20:01:22 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Fri Feb 10 20:01:22 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Feb 10 20:01:22 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Fri Feb 10 20:01:22 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0116.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Feb 11 08:13:25 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 08:13:25 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Feb 11 08:13:25 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Feb 11 08:13:26 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Feb 11 08:13:26 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 08:13:26 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Feb 11 08:13:26 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sat Feb 11 08:13:26 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Feb 11 08:13:26 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 08:13:26 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Sat Feb 11 08:13:26 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 08:13:26 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Feb 11 08:13:26 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sat Feb 11 08:13:26 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Sat Feb 11 08:13:27 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Feb 11 08:13:27 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 08:13:27 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Sat Feb 11 08:13:27 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 08:13:27 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Feb 11 08:13:27 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 08:13:28 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Feb 11 08:13:28 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Feb 11 08:13:28 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 08:13:28 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Sat Feb 11 08:13:30 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0117.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 08:13:30 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Sat Feb 11 08:13:30 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 08:13:30 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Sat Feb 11 08:13:31 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Feb 11 08:13:31 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 08:13:31 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Feb 11 08:13:31 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 08:13:31 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Feb 11 08:13:31 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 08:13:31 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Sat Feb 11 08:13:31 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 08:13:32 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Sat Feb 11 08:13:32 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 08:13:32 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 08:13:32 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Sat Feb 11 08:13:32 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 08:13:32 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sat Feb 11 08:13:34 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0117.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 08:13:34 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Sat Feb 11 08:13:34 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 08:13:34 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sat Feb 11 08:13:35 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0117.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Feb 11 12:02:55 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 12:02:55 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Feb 11 12:02:55 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Feb 11 12:02:56 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Feb 11 12:02:56 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 12:02:56 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Feb 11 12:02:56 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sat Feb 11 12:02:56 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Feb 11 12:02:56 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 12:02:56 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Sat Feb 11 12:02:56 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 12:02:56 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Feb 11 12:02:56 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sat Feb 11 12:02:56 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Sat Feb 11 12:02:56 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Feb 11 12:02:56 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 12:02:56 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Sat Feb 11 12:02:56 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 12:02:56 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Feb 11 12:02:56 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 12:02:56 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Feb 11 12:02:56 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Feb 11 12:02:56 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 12:02:56 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Sat Feb 11 12:02:58 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0118.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 12:02:58 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Sat Feb 11 12:02:58 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 12:02:58 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Sat Feb 11 12:02:58 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Feb 11 12:02:58 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 12:02:58 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Feb 11 12:02:58 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 12:02:58 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Feb 11 12:02:58 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 12:02:58 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Sat Feb 11 12:02:58 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 12:02:59 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Sat Feb 11 12:02:59 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 12:02:59 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 12:02:59 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Sat Feb 11 12:02:59 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 12:02:59 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sat Feb 11 12:02:59 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0118.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 12:02:59 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Sat Feb 11 12:02:59 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 12:02:59 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sat Feb 11 12:02:59 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0118.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Feb 11 16:01:14 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 16:01:15 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Feb 11 16:01:15 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Feb 11 16:01:15 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Feb 11 16:01:15 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 16:01:15 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Feb 11 16:01:15 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sat Feb 11 16:01:15 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Feb 11 16:01:15 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 16:01:15 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Sat Feb 11 16:01:15 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 16:01:15 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Feb 11 16:01:15 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sat Feb 11 16:01:15 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Sat Feb 11 16:01:15 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Feb 11 16:01:15 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 16:01:15 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Sat Feb 11 16:01:15 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 16:01:15 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Feb 11 16:01:15 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 16:01:15 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Feb 11 16:01:15 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Feb 11 16:01:15 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 16:01:15 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Sat Feb 11 16:01:15 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0119.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 16:01:15 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Sat Feb 11 16:01:15 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 16:01:15 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Sat Feb 11 16:01:15 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Feb 11 16:01:15 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 16:01:15 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Feb 11 16:01:15 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 16:01:15 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Feb 11 16:01:15 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 16:01:15 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Sat Feb 11 16:01:15 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 16:01:15 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Sat Feb 11 16:01:15 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 16:01:15 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 16:01:15 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Sat Feb 11 16:01:15 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 16:01:15 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sat Feb 11 16:01:16 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0119.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 16:01:16 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Sat Feb 11 16:01:16 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 16:01:16 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sat Feb 11 16:01:16 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0119.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Feb 11 20:01:08 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 20:01:08 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Feb 11 20:01:08 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Feb 11 20:01:08 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Feb 11 20:01:08 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 20:01:08 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Feb 11 20:01:08 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sat Feb 11 20:01:08 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sat Feb 11 20:01:08 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 20:01:08 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Sat Feb 11 20:01:08 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 20:01:08 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Feb 11 20:01:08 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sat Feb 11 20:01:08 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Sat Feb 11 20:01:08 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Sat Feb 11 20:01:08 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 20:01:08 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Sat Feb 11 20:01:08 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 20:01:08 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Feb 11 20:01:08 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 20:01:08 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Feb 11 20:01:08 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sat Feb 11 20:01:08 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 20:01:08 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Sat Feb 11 20:01:08 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0120.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 20:01:08 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Sat Feb 11 20:01:08 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 20:01:08 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Sat Feb 11 20:01:08 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Feb 11 20:01:08 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 20:01:08 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Feb 11 20:01:08 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 20:01:08 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sat Feb 11 20:01:08 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 20:01:08 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Sat Feb 11 20:01:08 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 20:01:08 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Sat Feb 11 20:01:09 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 20:01:09 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 20:01:09 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Sat Feb 11 20:01:09 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 20:01:09 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sat Feb 11 20:01:09 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0120.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 20:01:09 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Sat Feb 11 20:01:09 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sat Feb 11 20:01:09 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sat Feb 11 20:01:09 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0120.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Feb 12 08:10:04 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 08:10:06 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Feb 12 08:10:06 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Feb 12 08:10:06 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Feb 12 08:10:06 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 08:10:06 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Feb 12 08:10:07 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sun Feb 12 08:10:07 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Feb 12 08:10:07 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 08:10:07 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Sun Feb 12 08:10:07 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 08:10:07 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Feb 12 08:10:07 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sun Feb 12 08:10:08 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Sun Feb 12 08:10:08 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Feb 12 08:10:08 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 08:10:08 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Sun Feb 12 08:10:08 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 08:10:08 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Feb 12 08:10:08 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 08:10:09 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Feb 12 08:10:09 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Feb 12 08:10:09 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 08:10:09 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Sun Feb 12 08:10:11 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0121.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 08:10:11 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Sun Feb 12 08:10:11 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 08:10:11 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Sun Feb 12 08:10:11 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Feb 12 08:10:11 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 08:10:11 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Feb 12 08:10:11 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 08:10:12 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Feb 12 08:10:12 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 08:10:12 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Sun Feb 12 08:10:12 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 08:10:12 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Sun Feb 12 08:10:12 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 08:10:12 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 08:10:12 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Sun Feb 12 08:10:12 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 08:10:12 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sun Feb 12 08:10:13 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0121.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 08:10:13 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Sun Feb 12 08:10:14 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 08:10:14 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sun Feb 12 08:10:15 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0121.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Feb 12 12:03:00 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 12:03:01 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Feb 12 12:03:01 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Feb 12 12:03:01 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Feb 12 12:03:01 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 12:03:01 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Feb 12 12:03:01 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sun Feb 12 12:03:01 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Feb 12 12:03:01 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 12:03:01 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Sun Feb 12 12:03:01 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 12:03:01 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Feb 12 12:03:01 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sun Feb 12 12:03:01 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Sun Feb 12 12:03:01 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Feb 12 12:03:01 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 12:03:01 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Sun Feb 12 12:03:01 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 12:03:01 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Feb 12 12:03:01 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 12:03:01 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Feb 12 12:03:01 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Feb 12 12:03:01 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 12:03:01 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Sun Feb 12 12:03:03 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0122.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 12:03:03 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Sun Feb 12 12:03:03 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 12:03:03 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Sun Feb 12 12:03:03 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Feb 12 12:03:03 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 12:03:03 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Feb 12 12:03:03 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 12:03:03 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Feb 12 12:03:03 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 12:03:03 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Sun Feb 12 12:03:03 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 12:03:03 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Sun Feb 12 12:03:03 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 12:03:03 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 12:03:03 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Sun Feb 12 12:03:06 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 12:03:06 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sun Feb 12 12:03:06 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0122.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 12:03:06 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Sun Feb 12 12:03:06 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 12:03:06 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sun Feb 12 12:03:06 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0122.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Feb 12 16:01:21 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 16:01:21 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Feb 12 16:01:21 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Feb 12 16:01:21 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Feb 12 16:01:21 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 16:01:21 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Feb 12 16:01:21 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sun Feb 12 16:01:21 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Feb 12 16:01:21 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 16:01:21 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Sun Feb 12 16:01:21 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 16:01:21 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Feb 12 16:01:21 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sun Feb 12 16:01:21 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Sun Feb 12 16:01:21 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Feb 12 16:01:21 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 16:01:21 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Sun Feb 12 16:01:21 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 16:01:21 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Feb 12 16:01:21 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 16:01:21 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Feb 12 16:01:21 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Feb 12 16:01:21 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 16:01:21 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Sun Feb 12 16:01:21 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0123.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 16:01:21 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Sun Feb 12 16:01:21 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 16:01:21 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Sun Feb 12 16:01:21 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Feb 12 16:01:21 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 16:01:21 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Feb 12 16:01:21 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 16:01:22 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Feb 12 16:01:22 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 16:01:22 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Sun Feb 12 16:01:22 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 16:01:22 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Sun Feb 12 16:01:22 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 16:01:22 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 16:01:22 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Sun Feb 12 16:01:22 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 16:01:22 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sun Feb 12 16:01:22 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0123.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 16:01:22 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Sun Feb 12 16:01:22 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 16:01:22 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sun Feb 12 16:01:22 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0123.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Feb 12 20:01:10 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 20:01:10 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Feb 12 20:01:10 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Feb 12 20:01:10 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Feb 12 20:01:10 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 20:01:10 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Feb 12 20:01:10 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sun Feb 12 20:01:10 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Sun Feb 12 20:01:10 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 20:01:10 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Sun Feb 12 20:01:11 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 20:01:11 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Feb 12 20:01:11 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Sun Feb 12 20:01:11 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Sun Feb 12 20:01:11 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Sun Feb 12 20:01:11 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 20:01:11 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Sun Feb 12 20:01:11 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 20:01:11 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Feb 12 20:01:11 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 20:01:11 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Feb 12 20:01:11 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Sun Feb 12 20:01:11 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 20:01:11 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Sun Feb 12 20:01:11 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0124.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 20:01:11 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Sun Feb 12 20:01:11 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 20:01:11 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Sun Feb 12 20:01:11 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Feb 12 20:01:11 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 20:01:11 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Feb 12 20:01:11 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 20:01:11 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Sun Feb 12 20:01:11 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 20:01:11 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Sun Feb 12 20:01:11 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 20:01:11 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Sun Feb 12 20:01:11 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 20:01:11 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 20:01:11 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Sun Feb 12 20:01:11 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 20:01:11 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sun Feb 12 20:01:11 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0124.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 20:01:11 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Sun Feb 12 20:01:11 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Sun Feb 12 20:01:11 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Sun Feb 12 20:01:11 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0124.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Feb 13 08:18:04 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 08:18:05 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Feb 13 08:18:05 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Feb 13 08:18:06 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Feb 13 08:18:06 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 08:18:06 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Feb 13 08:18:06 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Mon Feb 13 08:18:06 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Feb 13 08:18:06 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 08:18:06 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Mon Feb 13 08:18:07 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 08:18:07 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Feb 13 08:18:07 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Mon Feb 13 08:18:07 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Mon Feb 13 08:18:07 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Feb 13 08:18:07 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 08:18:07 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Mon Feb 13 08:18:07 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 08:18:08 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Feb 13 08:18:08 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 08:18:08 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Feb 13 08:18:08 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Feb 13 08:18:08 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 08:18:08 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Mon Feb 13 08:18:15 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0125.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 08:18:16 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Mon Feb 13 08:18:16 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 08:18:16 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Mon Feb 13 08:18:19 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Feb 13 08:18:19 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 08:18:19 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Feb 13 08:18:19 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 08:18:19 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Feb 13 08:18:19 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 08:18:19 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Mon Feb 13 08:18:19 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 08:18:19 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Mon Feb 13 08:18:20 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 08:18:20 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 08:18:20 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Mon Feb 13 08:18:20 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 08:18:20 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Mon Feb 13 08:18:21 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0125.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 08:18:21 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Mon Feb 13 08:18:21 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 08:18:21 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Mon Feb 13 08:18:22 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0125.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Feb 13 12:03:20 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 12:03:20 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Feb 13 12:03:20 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Feb 13 12:03:20 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Feb 13 12:03:20 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 12:03:20 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Feb 13 12:03:20 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Mon Feb 13 12:03:20 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Feb 13 12:03:20 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 12:03:20 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Mon Feb 13 12:03:20 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 12:03:20 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Feb 13 12:03:20 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Mon Feb 13 12:03:20 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Mon Feb 13 12:03:20 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Feb 13 12:03:20 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 12:03:20 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Mon Feb 13 12:03:20 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 12:03:20 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Feb 13 12:03:20 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 12:03:22 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Feb 13 12:03:22 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Feb 13 12:03:23 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 12:03:23 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Mon Feb 13 12:03:24 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0126.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 12:03:24 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Mon Feb 13 12:03:24 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 12:03:24 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Mon Feb 13 12:03:24 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Feb 13 12:03:24 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 12:03:24 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Feb 13 12:03:24 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 12:03:24 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Feb 13 12:03:24 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 12:03:24 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Mon Feb 13 12:03:24 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 12:03:24 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Mon Feb 13 12:03:24 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 12:03:24 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 12:03:24 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Mon Feb 13 12:03:25 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 12:03:25 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Mon Feb 13 12:03:25 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0126.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 12:03:25 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Mon Feb 13 12:03:25 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 12:03:25 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Mon Feb 13 12:03:25 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0126.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Feb 13 16:01:34 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 16:01:34 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Feb 13 16:01:34 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Feb 13 16:01:34 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Feb 13 16:01:35 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 16:01:35 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Feb 13 16:01:35 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Mon Feb 13 16:01:35 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Feb 13 16:01:35 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 16:01:35 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Mon Feb 13 16:01:35 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 16:01:35 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Feb 13 16:01:35 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Mon Feb 13 16:01:35 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Mon Feb 13 16:01:35 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Feb 13 16:01:35 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 16:01:35 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Mon Feb 13 16:01:35 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 16:01:35 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Feb 13 16:01:35 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 16:01:35 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Feb 13 16:01:35 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Feb 13 16:01:35 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 16:01:35 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Mon Feb 13 16:01:35 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0127.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 16:01:35 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Mon Feb 13 16:01:35 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 16:01:35 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Mon Feb 13 16:01:35 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Feb 13 16:01:35 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 16:01:35 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Feb 13 16:01:35 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 16:01:35 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Feb 13 16:01:35 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 16:01:35 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Mon Feb 13 16:01:35 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 16:01:35 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Mon Feb 13 16:01:35 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 16:01:35 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 16:01:35 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Mon Feb 13 16:01:35 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 16:01:36 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Mon Feb 13 16:01:36 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0127.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 16:01:36 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Mon Feb 13 16:01:36 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 16:01:36 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Mon Feb 13 16:01:36 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0127.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Feb 13 20:01:17 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 20:01:18 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Feb 13 20:01:18 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Feb 13 20:01:18 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Feb 13 20:01:18 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 20:01:18 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Feb 13 20:01:18 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Mon Feb 13 20:01:18 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Mon Feb 13 20:01:18 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 20:01:18 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Mon Feb 13 20:01:18 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 20:01:18 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Feb 13 20:01:18 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Mon Feb 13 20:01:18 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Mon Feb 13 20:01:18 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Mon Feb 13 20:01:18 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 20:01:18 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Mon Feb 13 20:01:18 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 20:01:18 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Feb 13 20:01:18 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 20:01:18 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Feb 13 20:01:18 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Mon Feb 13 20:01:18 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 20:01:18 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Mon Feb 13 20:01:18 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0128.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 20:01:18 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Mon Feb 13 20:01:18 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 20:01:18 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Mon Feb 13 20:01:18 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Feb 13 20:01:18 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 20:01:18 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Feb 13 20:01:18 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 20:01:18 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Mon Feb 13 20:01:18 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 20:01:18 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Mon Feb 13 20:01:18 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 20:01:18 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Mon Feb 13 20:01:18 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 20:01:18 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 20:01:18 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Mon Feb 13 20:01:18 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 20:01:18 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Mon Feb 13 20:01:19 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0128.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 20:01:19 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Mon Feb 13 20:01:19 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Mon Feb 13 20:01:19 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Mon Feb 13 20:01:19 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0128.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Feb 14 08:20:21 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 08:20:25 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Feb 14 08:20:25 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Feb 14 08:20:25 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Feb 14 08:20:26 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 08:20:26 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Feb 14 08:20:27 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Tue Feb 14 08:20:27 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Feb 14 08:20:28 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 08:20:28 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Tue Feb 14 08:20:28 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 08:20:28 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Feb 14 08:20:28 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Tue Feb 14 08:20:29 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Tue Feb 14 08:20:29 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Feb 14 08:20:29 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 08:20:29 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Tue Feb 14 08:20:29 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 08:20:30 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Feb 14 08:20:30 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 08:20:30 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Feb 14 08:20:30 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Feb 14 08:20:30 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 08:20:31 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Tue Feb 14 08:20:38 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0129.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 08:20:38 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Tue Feb 14 08:20:38 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 08:20:38 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Tue Feb 14 08:20:38 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Feb 14 08:20:38 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 08:20:39 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Feb 14 08:20:39 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 08:20:39 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Feb 14 08:20:39 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 08:20:39 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Tue Feb 14 08:20:40 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 08:20:40 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Tue Feb 14 08:20:40 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 08:20:41 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 08:20:41 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Tue Feb 14 08:20:41 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 08:20:42 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Tue Feb 14 08:20:43 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0129.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 08:20:43 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Tue Feb 14 08:20:44 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 08:20:44 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Tue Feb 14 08:20:45 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0129.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Feb 14 12:03:37 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 12:03:37 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Feb 14 12:03:37 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Feb 14 12:03:37 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Feb 14 12:03:37 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 12:03:37 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Feb 14 12:03:37 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Tue Feb 14 12:03:37 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Feb 14 12:03:37 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 12:03:37 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Tue Feb 14 12:03:38 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 12:03:38 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Feb 14 12:03:38 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Tue Feb 14 12:03:38 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Tue Feb 14 12:03:38 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Feb 14 12:03:38 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 12:03:38 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Tue Feb 14 12:03:38 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 12:03:38 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Feb 14 12:03:38 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 12:03:38 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Feb 14 12:03:38 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Feb 14 12:03:38 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 12:03:38 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Tue Feb 14 12:03:40 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0130.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 12:03:40 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Tue Feb 14 12:03:40 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 12:03:40 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Tue Feb 14 12:03:40 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Feb 14 12:03:40 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 12:03:40 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Feb 14 12:03:40 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 12:03:40 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Feb 14 12:03:40 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 12:03:40 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Tue Feb 14 12:03:40 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 12:03:40 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Tue Feb 14 12:03:40 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 12:03:40 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 12:03:40 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Tue Feb 14 12:03:40 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 12:03:41 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Tue Feb 14 12:03:41 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0130.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 12:03:41 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Tue Feb 14 12:03:41 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 12:03:41 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Tue Feb 14 12:03:41 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0130.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Feb 14 16:01:48 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 16:01:50 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Feb 14 16:01:50 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Feb 14 16:01:50 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Feb 14 16:01:50 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 16:01:50 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Feb 14 16:01:50 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Tue Feb 14 16:01:50 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Feb 14 16:01:50 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 16:01:50 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Tue Feb 14 16:01:51 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 16:01:51 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Feb 14 16:01:51 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Tue Feb 14 16:01:51 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Tue Feb 14 16:01:51 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Feb 14 16:01:51 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 16:01:51 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Tue Feb 14 16:01:51 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 16:01:51 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Feb 14 16:01:51 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 16:01:51 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Feb 14 16:01:51 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Feb 14 16:01:52 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 16:01:52 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Tue Feb 14 16:01:52 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0131.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 16:01:52 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Tue Feb 14 16:01:52 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 16:01:52 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Tue Feb 14 16:01:52 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Feb 14 16:01:52 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 16:01:52 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Feb 14 16:01:52 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 16:01:52 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Feb 14 16:01:52 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 16:01:52 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Tue Feb 14 16:01:52 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 16:01:52 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Tue Feb 14 16:01:52 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 16:01:52 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 16:01:52 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Tue Feb 14 16:01:52 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 16:01:52 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Tue Feb 14 16:01:52 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0131.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 16:01:52 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Tue Feb 14 16:01:52 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 16:01:52 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Tue Feb 14 16:01:52 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0131.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Feb 14 20:01:21 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 20:01:21 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Feb 14 20:01:21 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Feb 14 20:01:21 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Feb 14 20:01:21 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 20:01:21 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Feb 14 20:01:21 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Tue Feb 14 20:01:21 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Tue Feb 14 20:01:21 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 20:01:21 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Tue Feb 14 20:01:21 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 20:01:21 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Feb 14 20:01:21 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Tue Feb 14 20:01:21 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Tue Feb 14 20:01:21 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Tue Feb 14 20:01:21 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 20:01:21 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Tue Feb 14 20:01:21 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 20:01:21 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Feb 14 20:01:21 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 20:01:21 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Feb 14 20:01:21 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Tue Feb 14 20:01:21 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 20:01:21 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Tue Feb 14 20:01:21 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0132.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 20:01:21 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Tue Feb 14 20:01:21 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 20:01:21 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Tue Feb 14 20:01:21 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Feb 14 20:01:21 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 20:01:21 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Feb 14 20:01:22 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 20:01:22 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Tue Feb 14 20:01:22 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 20:01:22 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Tue Feb 14 20:01:22 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 20:01:22 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Tue Feb 14 20:01:22 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 20:01:22 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 20:01:22 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Tue Feb 14 20:01:22 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 20:01:22 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Tue Feb 14 20:01:22 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0132.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 20:01:22 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Tue Feb 14 20:01:22 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Tue Feb 14 20:01:22 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Tue Feb 14 20:01:22 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0132.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Feb 15 08:30:23 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 08:30:26 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Feb 15 08:30:27 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Feb 15 08:30:27 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 15 08:30:27 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 08:30:28 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 15 08:30:28 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Wed Feb 15 08:30:28 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Feb 15 08:30:29 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 08:30:29 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Wed Feb 15 08:30:29 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 08:30:29 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Feb 15 08:30:29 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Wed Feb 15 08:30:29 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Wed Feb 15 08:30:30 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Feb 15 08:30:31 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 08:30:31 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Wed Feb 15 08:30:33 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 08:30:33 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 15 08:30:34 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 08:30:34 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 15 08:30:34 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 15 08:30:35 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 08:30:35 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Wed Feb 15 08:31:05 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0133.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 08:31:06 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Wed Feb 15 08:31:06 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 08:31:07 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Wed Feb 15 08:31:07 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Feb 15 08:31:08 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 08:31:08 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Feb 15 08:31:08 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 08:31:09 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Feb 15 08:31:09 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 08:31:10 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Wed Feb 15 08:31:10 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 08:31:10 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Wed Feb 15 08:31:11 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 08:31:11 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 08:31:12 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Wed Feb 15 08:31:12 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 08:31:12 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Wed Feb 15 08:31:17 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0133.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 08:31:17 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Wed Feb 15 08:31:18 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 08:31:18 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Wed Feb 15 08:31:20 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0133.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Feb 15 12:05:46 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 12:05:47 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Feb 15 12:05:47 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Feb 15 12:05:47 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 15 12:05:47 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 12:05:47 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 15 12:05:47 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Wed Feb 15 12:05:47 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Feb 15 12:05:47 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 12:05:47 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Wed Feb 15 12:05:47 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 12:05:47 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Feb 15 12:05:47 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Wed Feb 15 12:05:47 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Wed Feb 15 12:05:47 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Feb 15 12:05:48 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 12:05:48 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Wed Feb 15 12:05:48 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 12:05:48 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 15 12:05:48 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 12:05:48 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 15 12:05:48 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 15 12:05:48 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 12:05:48 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Wed Feb 15 12:05:50 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0134.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 12:05:50 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Wed Feb 15 12:05:50 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 12:05:50 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Wed Feb 15 12:05:50 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Feb 15 12:05:50 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 12:05:50 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Feb 15 12:05:50 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 12:05:51 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Feb 15 12:05:51 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 12:05:51 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Wed Feb 15 12:05:53 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 12:05:53 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Wed Feb 15 12:05:53 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 12:05:53 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 12:05:53 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Wed Feb 15 12:05:53 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 12:05:53 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Wed Feb 15 12:05:54 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0134.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 12:05:54 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Wed Feb 15 12:05:54 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 12:05:54 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Wed Feb 15 12:05:54 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0134.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Feb 15 16:01:43 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 16:01:43 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Feb 15 16:01:43 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Feb 15 16:01:43 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 15 16:01:43 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 16:01:43 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 15 16:01:43 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Wed Feb 15 16:01:43 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Feb 15 16:01:43 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 16:01:43 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Wed Feb 15 16:01:43 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 16:01:43 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Feb 15 16:01:43 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Wed Feb 15 16:01:43 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Wed Feb 15 16:01:43 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Feb 15 16:01:43 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 16:01:43 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Wed Feb 15 16:01:43 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 16:01:43 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 15 16:01:43 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 16:01:43 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 15 16:01:43 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 15 16:01:43 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 16:01:43 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Wed Feb 15 16:01:43 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0135.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 16:01:43 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Wed Feb 15 16:01:43 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 16:01:43 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Wed Feb 15 16:01:43 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Feb 15 16:01:43 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 16:01:43 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Feb 15 16:01:43 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 16:01:43 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Feb 15 16:01:44 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 16:01:44 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Wed Feb 15 16:01:44 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 16:01:44 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Wed Feb 15 16:01:44 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 16:01:44 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 16:01:44 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Wed Feb 15 16:01:44 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 16:01:44 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Wed Feb 15 16:01:44 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0135.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 16:01:44 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Wed Feb 15 16:01:44 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 16:01:44 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Wed Feb 15 16:01:44 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0135.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Feb 15 19:28:15 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 19:28:15 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Feb 15 19:28:15 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Feb 15 19:28:15 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 15 19:28:15 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 19:28:15 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 15 19:28:15 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Wed Feb 15 19:28:16 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Feb 15 19:28:16 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 19:28:16 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Wed Feb 15 19:28:16 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 19:28:16 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Feb 15 19:28:19 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Wed Feb 15 19:28:19 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Wed Feb 15 19:28:19 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Feb 15 19:28:19 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 19:28:21 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Wed Feb 15 19:28:21 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 19:28:21 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 15 19:28:21 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 19:28:21 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 15 19:28:21 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 15 19:28:21 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 19:28:21 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Wed Feb 15 19:28:22 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0136.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 19:28:22 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Wed Feb 15 19:28:22 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 19:28:22 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Wed Feb 15 19:28:22 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Feb 15 19:28:22 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 19:28:22 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Feb 15 19:28:22 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 19:28:22 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Feb 15 19:28:22 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 19:28:22 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Wed Feb 15 19:28:22 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 19:28:22 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Wed Feb 15 19:28:22 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 19:28:22 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 19:28:22 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Wed Feb 15 19:28:22 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 19:28:22 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Wed Feb 15 19:28:22 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0136.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 19:28:22 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Wed Feb 15 19:28:22 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 19:28:22 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Wed Feb 15 19:28:22 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0136.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Feb 15 20:14:30 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 20:14:32 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Feb 15 20:14:32 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Feb 15 20:14:33 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 15 20:14:33 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 20:14:33 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 15 20:14:33 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Wed Feb 15 20:14:34 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Wed Feb 15 20:14:34 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 20:14:34 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Wed Feb 15 20:14:34 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 20:14:34 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Feb 15 20:14:34 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Wed Feb 15 20:14:35 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Wed Feb 15 20:14:35 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Wed Feb 15 20:14:35 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 20:14:35 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Wed Feb 15 20:14:35 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 20:14:36 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 15 20:14:36 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 20:14:36 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 15 20:14:36 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Wed Feb 15 20:14:38 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 20:14:38 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Wed Feb 15 20:14:40 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0137.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 20:14:40 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Wed Feb 15 20:14:41 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 20:14:41 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Wed Feb 15 20:14:41 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Feb 15 20:14:41 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 20:14:41 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Feb 15 20:14:41 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 20:14:41 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Wed Feb 15 20:14:41 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 20:14:41 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Wed Feb 15 20:14:42 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 20:14:42 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Wed Feb 15 20:14:42 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 20:14:43 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 20:14:43 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Wed Feb 15 20:14:44 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 20:14:44 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Wed Feb 15 20:14:47 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0137.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 20:14:47 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Wed Feb 15 20:14:47 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Wed Feb 15 20:14:47 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Wed Feb 15 20:14:48 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0137.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Feb 16 08:48:07 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 16 08:48:09 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Feb 16 08:48:10 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Feb 16 08:48:10 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Feb 16 08:48:10 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 16 08:48:11 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Feb 16 08:48:11 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Thu Feb 16 08:48:12 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Thu Feb 16 08:48:12 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 16 08:48:13 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Thu Feb 16 08:48:13 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 16 08:48:13 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Feb 16 08:48:13 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Thu Feb 16 08:48:14 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Thu Feb 16 08:48:14 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Thu Feb 16 08:48:14 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 16 08:48:15 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Thu Feb 16 08:48:15 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 16 08:48:15 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Feb 16 08:48:15 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 16 08:48:15 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Feb 16 08:48:15 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Thu Feb 16 08:48:15 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 16 08:48:15 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Thu Feb 16 08:48:25 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0138.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 16 08:48:25 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Thu Feb 16 08:48:25 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 16 08:48:25 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Thu Feb 16 08:48:25 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Feb 16 08:48:25 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 16 08:48:25 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Feb 16 08:48:25 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 16 08:48:25 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Thu Feb 16 08:48:25 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 16 08:48:25 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Thu Feb 16 08:48:26 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 16 08:48:26 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Thu Feb 16 08:48:27 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 16 08:48:27 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 16 08:48:27 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Thu Feb 16 08:48:27 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 16 08:48:27 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Thu Feb 16 08:48:29 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0138.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 16 08:48:31 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Thu Feb 16 08:48:32 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Thu Feb 16 08:48:32 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Thu Feb 16 08:48:35 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0138.htm From tjaeckle at zes.com Mon Jan 3 14:25:30 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Mar 31 16:33:52 2006 Subject: [egenix-users] mxDateTime calculation error Message-ID: Hello! I found an error when executing following Python script: import mx.DateTime date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) print date date = date - 0 print date The result should be: 2005-01-02 12:42:27.64 2005-01-02 12:42:27.63 So the subtraction of 0 seems to change the time! This reduction of 1/100 second happens not always but only with several numbers (like 27.64s in above example). This subtraction happens for example at the end of the DateTimeFrom() function (where on offset of 0 is subtracted), so I can't work around it. Is this bug known? Is there any solution? Thanks in advance Best regards Thomas J?ckle From mal at egenix.com Mon Jan 3 14:47:10 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Mar 31 16:33:52 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <41D94CDE.60907@egenix.com> J?ckle Thomas wrote: > Hello! > > I found an error when executing following Python script: > > import mx.DateTime > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > print date > date = date - 0 > print date > > The result should be: > 2005-01-02 12:42:27.64 > 2005-01-02 12:42:27.63 > > So the subtraction of 0 seems to change the time! This reduction of 1/100 > second happens not always but only with several numbers (like 27.64s in > above example). > This subtraction happens for example at the end of the DateTimeFrom() > function (where on offset of 0 is subtracted), so I can't work around it. > > Is this bug known? Is there any solution? This sounds like a bug on the platform you are using or with the compiler. Which version of egenix-mx-base are you using ? Testing with the latest snapshot of egenix-mx-base, I don't get this output: >>> import mx.DateTime >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) >>> print date 2005-01-02 12:42:27.64 >>> print date + 0 2005-01-02 12:42:27.64 >>> print date - 0 2005-01-02 12:42:27.64 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tjaeckle at zes.com Mon Jan 3 16:20:12 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Mar 31 16:33:52 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <41D94CDE.60907@egenix.com> Message-ID: Hello ! Thanks for the fast answer. I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four combinations have produced the same (fail) result! Best regards > -----Original Message----- > From: M.-A. Lemburg [mailto:mal@egenix.com] > Sent: Monday, January 03, 2005 2:47 PM > To: tjaeckle@zes.com > Cc: egenix-users@lists.egenix.com > Subject: Re: [egenix-users] mxDateTime calculation error > > > J?ckle Thomas wrote: > > Hello! > > > > I found an error when executing following Python script: > > > > import mx.DateTime > > date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > > print date > > date = date - 0 > > print date > > > > The result should be: > > 2005-01-02 12:42:27.64 > > 2005-01-02 12:42:27.63 > > > > So the subtraction of 0 seems to change the time! This > reduction of 1/100 > > second happens not always but only with several numbers (like 27.64s in > > above example). > > This subtraction happens for example at the end of the DateTimeFrom() > > function (where on offset of 0 is subtracted), so I can't work > around it. > > > > Is this bug known? Is there any solution? > > This sounds like a bug on the platform you are using or > with the compiler. > > Which version of egenix-mx-base are you using ? Testing with > the latest snapshot of egenix-mx-base, I don't get this output: > > >>> import mx.DateTime > >>> date = mx.DateTime.DateTime(2005, 1, 2, 12, 42, 27.64) > >>> print date > 2005-01-02 12:42:27.64 > >>> print date + 0 > 2005-01-02 12:42:27.64 > >>> print date - 0 > 2005-01-02 12:42:27.64 > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 03 2005) > >>> Python/Zope Consulting and Support ... http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python 2.4 > > ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: > > From charlie at egenix.com Mon Jan 3 17:47:48 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Mar 31 16:33:52 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: References: Message-ID: <20050103174748.28439.23@Zeta.1104742935.fake> On 2005-01-03 at 16:20:12 [+0100], J?ckle Thomas wrote: > Hello ! > > Thanks for the fast answer. > I tried with versions 2.0.5 and 2.0.6 on Win95 and WinXP. All four > combinations have produced the same (fail) result! May be you should try a more recent version of mx.DateTime ? No errors here with DateTime 2.1.0 on Windows 2000. Charlie From erik.myllymaki at aviawest.com Mon Jan 3 13:13:18 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Mar 31 16:33:52 2006 Subject: [egenix-users] max_rows Message-ID: <41D9B56E.7020703@aviawest.com> I am using ZmxODBC DA and I seem to be butting up against a 1000 row limit on SELECT statements - where can I change this? Thanks. From mal at egenix.com Mon Jan 3 22:16:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Mar 31 16:33:52 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B56E.7020703@aviawest.com> References: <41D9B56E.7020703@aviawest.com> Message-ID: <41D9B62C.2060204@egenix.com> Erik Myllymaki wrote: > I am using ZmxODBC DA and I seem to be butting up against a 1000 row > limit on SELECT statements - where can I change this? This 1000 row limit is the default value used by Z SQL Methods. To change this value, edit the attributes of the Z SQL Method repsonsible for the query. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 03 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Mon Jan 3 13:21:28 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Mar 31 16:33:52 2006 Subject: [egenix-users] max_rows In-Reply-To: <41D9B62C.2060204@egenix.com> References: <41D9B56E.7020703@aviawest.com> <41D9B62C.2060204@egenix.com> Message-ID: <41D9B758.50102@aviawest.com> thank you. M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> I am using ZmxODBC DA and I seem to be butting up against a 1000 row >> limit on SELECT statements - where can I change this? > > > This 1000 row limit is the default value used by Z SQL Methods. > > To change this value, edit the attributes of the Z SQL Method > repsonsible for the query. > From maneeshsingh at yahoo.com Tue Jan 4 01:10:23 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Fri Mar 31 16:33:52 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41935919.5050004@egenix.com> Message-ID: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Hi, I have successfully installed freetds & unixODBC and I am able to connect to the remote MS SQL Server 2000 database through tsql & isql from my Fedora Core 2 machine. I need to connect to the MS SQl DB through Python & hence went for mxODBC. I installed the RPM & later also tried the source with the same negative result: Traceback (most recent call last): File "db3.py", line 4, in ? import mx.ODBC.unixODBC File "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", line 8, in ? from mxODBC import * ImportError: libiodbcinst.so.2: cannot open shared object file: No such file or directory ------------------------------------------ The code (db3.py) under test is as follows: #!/usr/bin/python2.3 import mx.ODBC.unixODBC dsn="ps0196" conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", "newuser") print "Content-Type: text/plain" print cursorhandle=conn.cursor() print "MySQL Databse via mxODBC....\n" cursorhandle.execute("select * from tb_mis_team") for i in cursorhandle.fetchall(): print i print cursorhandle.fetchall() for i in cursorhandle.fetchall(): print i ------------------------------------------ [root@ps0778 unixODBC]# pwd /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC [root@ps0778 unixODBC]# ldd ./mxODBC.so linux-gate.so.1 => (0x00399000) libodbc.so.1 => /usr/lib/libodbc.so.1 (0x00506000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00111000) libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) libiodbcinst.so.2 => not found libdl.so.2 => /lib/libdl.so.2 (0x00db8000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0089d000) ------------------------------------------ I had earlier tried to install iODBC without success. The library libiodbcinst.so.2 exists at /usr/local/lib. I need to use unixODBC and not iODBC. Why is it asking for iODBC libraries when unixODBC is present? Was I supposed to use setup.in file the source code folders to configure something? Please help! Thanks! Maneesh. __________________________________ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com From tjaeckle at zes.com Tue Jan 4 10:30:36 2005 From: tjaeckle at zes.com (=?iso-8859-1?Q?J=E4ckle_Thomas?=) Date: Fri Mar 31 16:33:52 2006 Subject: [egenix-users] mxDateTime calculation error In-Reply-To: <20050103174748.28439.23@Zeta.1104742935.fake> Message-ID: > > May be you should try a more recent version of mx.DateTime ? No > errors here > with DateTime 2.1.0 on Windows 2000. > > Charlie 2.1.0 B5 runs with Win95 (WinXP not tested yet, but I'm optimistic) Thank you!! Thomas From mal at egenix.com Tue Jan 4 12:03:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Mar 31 16:33:52 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <20050104091023.73530.qmail@web14224.mail.yahoo.com> References: <20050104091023.73530.qmail@web14224.mail.yahoo.com> Message-ID: <41DA77E9.6080104@egenix.com> Maneesh Singh wrote: > Hi, > I have successfully installed freetds & unixODBC > and I am able to connect to the remote MS SQL Server > 2000 database through tsql & isql from my Fedora Core > 2 machine. I need to connect to the MS SQl DB through > Python & hence went for mxODBC. I installed the RPM & > later also tried the source with the same negative > result: > Traceback (most recent call last): > File "db3.py", line 4, in ? > import mx.ODBC.unixODBC > File > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > line 8, in ? > from mxODBC import * > ImportError: libiodbcinst.so.2: cannot open shared > object file: No such file or directory > ------------------------------------------ > > The code (db3.py) under test is as follows: > > > #!/usr/bin/python2.3 > > import mx.ODBC.unixODBC > > dsn="ps0196" > > conn=mx.ODBC.unixODBC.Connect (dsn, "maneesh_singh", > "newuser") > > print "Content-Type: text/plain" > print > > cursorhandle=conn.cursor() > > print "MySQL Databse via mxODBC....\n" > cursorhandle.execute("select * from tb_mis_team") > > for i in cursorhandle.fetchall(): > print i > > print cursorhandle.fetchall() > > for i in cursorhandle.fetchall(): > print i > ------------------------------------------ > [root@ps0778 unixODBC]# pwd > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > linux-gate.so.1 => (0x00399000) > libodbc.so.1 => /usr/lib/libodbc.so.1 > (0x00506000) > libpthread.so.0 => /lib/tls/libpthread.so.0 > (0x00111000) > libc.so.6 => /lib/tls/libc.so.6 (0x006e9000) > libiodbcinst.so.2 => not found > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > (0x0089d000) > > ------------------------------------------ > > I had earlier tried to install iODBC without > success. The library libiodbcinst.so.2 exists at > /usr/local/lib. I need to use unixODBC and not iODBC. You should remove the complete iODBC installation and then recompile mxODBC from source. It may also help to edit mxCOMMERCIAL.py and comment out the iODBC section in that file. > Why is it asking for iODBC libraries when unixODBC is > present? Was I supposed to use setup.in file the > source code folders to configure something? Please > help! It is likely that the linker was picking up libs that belonged to iODBC rather than unixODBC. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From tupteq at tlen.pl Tue Jan 4 17:17:02 2005 From: tupteq at tlen.pl (Marcin) Date: Fri Mar 31 16:33:52 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem Message-ID: <382760555.20050104171702@tlen.pl> Hi, I recently found mxODBC lib and I decided to use it with MS SQL Server. It worked fine until i tried to use ntext fields and short INSERT syntax (INSERT INTO tab VALUES(val1, ...)). The following script: from mx.ODBC.Windows import * db = connect('DSN', 'login', 'pass') db.stringformat = UNICODE_STRINGFORMAT c = db.cursor() c.execute('create table zxcvb (x ntext)') c.execute('insert into zxcvb values(?)', (None,)) c.execute('insert into zxcvb values(?)', (u'anything',)) raises exception in last line and returns: Traceback (most recent call last): File "test.py", line 15, in ? c.execute('insert into zxcvb values(?)', (u'anything',)) mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) But it's enough to change last line to: c.execute('insert into zxcvb (x) values(?)', (u'anything',)) or use other cursor than used with None insert, but this sucks. Is it my, server, driver or mODBC bug? Client specs: Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL Server ODBC Driver v.2000.81.9042.00 (2003-10-27) Server specs: OS: Windows XP Home SQL: MS SQL Server 2000 Trial v.8.00.194 -- Marcin From mal at egenix.com Tue Jan 4 18:30:05 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Mar 31 16:33:52 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <41DAD29D.9070601@egenix.com> Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? This sounds a lot like a driver/server issue. Could you try to execute the two inserts on two different cursors and see whether that makes a difference ? (ie. simply insert c = db.cursor() between the two .execute() calls) It is possible that the driver is doing some sort of caching of the column types based on what you pass in as value. Since None is passed in as NULL it is possible that the caching mechanism defaults to the wrong type. Note that ntext touches two areas in ODBC (and other DB interface mechanisms) that often cause problems: 1. it is a long text field capable of storing huge amounts of data and thus needs special treatment 2. it uses Unicode for storage which is rather new in the database world (although support is getting a lot better recently) > Client specs: > Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL > Server ODBC Driver v.2000.81.9042.00 (2003-10-27) > > Server specs: > OS: Windows XP Home > SQL: MS SQL Server 2000 Trial v.8.00.194 > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 04 2005) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2004-12-06: Released eGenix mx Extensions for Python 2.4 ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: From charlie at egenix.com Tue Jan 4 19:45:04 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Mar 31 16:33:52 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <382760555.20050104171702@tlen.pl> References: <382760555.20050104171702@tlen.pl> Message-ID: <20050104194504.18453.14@Zeta.1104839330.fake> Hi, just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that switching between encodings is what is upsetting the driver and as Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". Just out of interest, what is wrong with: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > or use other cursor than used with None insert, but this sucks. Surely, it is always better to explicitly relation attributes in queries? Charlie On 2005-01-04 at 17:17:02 [+0100], Marcin wrote: > Hi, > > I recently found mxODBC lib and I decided to use it with MS SQL > Server. It worked fine until i tried to use ntext fields and short > INSERT syntax (INSERT INTO tab VALUES(val1, ...)). > The following script: > > from mx.ODBC.Windows import * > > db = connect('DSN', 'login', 'pass') > db.stringformat = UNICODE_STRINGFORMAT > c = db.cursor() > > c.execute('create table zxcvb (x ntext)') > c.execute('insert into zxcvb values(?)', (None,)) > c.execute('insert into zxcvb values(?)', (u'anything',)) > > > raises exception in last line and returns: > > Traceback (most recent call last): > File "test.py", line 15, in ? > c.execute('insert into zxcvb values(?)', (u'anything',)) > mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server > Driver][SQL Server]Implicit conversion from data type ntext to char is not > allowed. Use the CONVERT function to run this query.', 4579) > > But it's enough to change last line to: > c.execute('insert into zxcvb (x) values(?)', (u'anything',)) > or use other cursor than used with None insert, but this sucks. > Is it my, server, driver or mODBC bug? From maneeshsingh at yahoo.com Tue Jan 4 22:32:14 2005 From: maneeshsingh at yahoo.com (Maneesh Singh) Date: Fri Mar 31 16:33:52 2006 Subject: [egenix-users] Problem with Python mxODBC In-Reply-To: <41DA77E9.6080104@egenix.com> Message-ID: <20050105063214.42929.qmail@web14225.mail.yahoo.com> Hi Marc, You had suggested I remove all iODBC libraries & recompile from source. I had tried them after reading his reply but the errors still remained. After that I ran 'ldconfig' so that it reconfigures the dynamic linker run-time bindings. It did, and things are working fine since. Thanks! Maneesh. --- "M.-A. Lemburg" wrote: > Maneesh Singh wrote: > > Hi, > > I have successfully installed freetds & > unixODBC > > and I am able to connect to the remote MS SQL > Server > > 2000 database through tsql & isql from my Fedora > Core > > 2 machine. I need to connect to the MS SQl DB > through > > Python & hence went for mxODBC. I installed the > RPM & > > later also tried the source with the same negative > > result: > > Traceback (most recent call last): > > File "db3.py", line 4, in ? > > import mx.ODBC.unixODBC > > File > > > "/usr/lib/python2.3/site-packages/mx/ODBC/unixODBC/__init__.py", > > line 8, in ? > > from mxODBC import * > > ImportError: libiodbcinst.so.2: cannot open shared > > object file: No such file or directory > > ------------------------------------------ > > > > The code (db3.py) under test is as follows: > > > > > > #!/usr/bin/python2.3 > > > > import mx.ODBC.unixODBC > > > > dsn="ps0196" > > > > conn=mx.ODBC.unixODBC.Connect (dsn, > "maneesh_singh", > > "newuser") > > > > print "Content-Type: text/plain" > > print > > > > cursorhandle=conn.cursor() > > > > print "MySQL Databse via mxODBC....\n" > > cursorhandle.execute("select * from tb_mis_team") > > > > for i in cursorhandle.fetchall(): > > print i > > > > print cursorhandle.fetchall() > > > > for i in cursorhandle.fetchall(): > > print i > > ------------------------------------------ > > [root@ps0778 unixODBC]# pwd > > /usr/lib/python2.3/site-packages/mx/ODBC/unixODBC > > > > [root@ps0778 unixODBC]# ldd ./mxODBC.so > > linux-gate.so.1 => (0x00399000) > > libodbc.so.1 => /usr/lib/libodbc.so.1 > > (0x00506000) > > libpthread.so.0 => > /lib/tls/libpthread.so.0 > > (0x00111000) > > libc.so.6 => /lib/tls/libc.so.6 > (0x006e9000) > > libiodbcinst.so.2 => not found > > libdl.so.2 => /lib/libdl.so.2 (0x00db8000) > > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 > > (0x0089d000) > > > > ------------------------------------------ > > > > I had earlier tried to install iODBC without > > success. The library libiodbcinst.so.2 exists at > > /usr/local/lib. I need to use unixODBC and not > iODBC. > > You should remove the complete iODBC installation > and > then recompile mxODBC from source. > > It may also help to edit mxCOMMERCIAL.py and comment > out > the iODBC section in that file. > > > Why is it asking for iODBC libraries when unixODBC > is > > present? Was I supposed to use setup.in file the > > source code folders to configure something? Please > > help! > > It is likely that the linker was picking up libs > that > belonged to iODBC rather than unixODBC. > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the > Source (#1, Jan 04 2005) > >>> Python/Zope Consulting and Support ... > http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... > http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ... > http://python.egenix.com/ > ________________________________________________________________________ > 2004-12-06: Released eGenix mx Extensions for Python > 2.4 > > ::: Try mxODBC.Zope.DA for > Windows,Linux,Solaris,FreeBSD for free ! :::: > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From tupteq at tlen.pl Wed Jan 5 14:12:14 2005 From: tupteq at tlen.pl (Marcin) Date: Fri Mar 31 16:33:52 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050104194504.18453.14@Zeta.1104839330.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> Message-ID: <1577611449.20050105141214@tlen.pl> Hello Charlie, Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that > switching between encodings is what is upsetting the driver and as > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". MIXED_STRINGFORMAT changed nothing, the same error :( I found one more way to exec this query without change - executedirect(). > Just out of interest, what is wrong with: >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? >> or use other cursor than used with None insert, but this sucks. > Surely, it is always better to explicitly relation attributes in queries? I have tables dynamically generated by app, I don't care for field names, information like: 'first field is int, second ntext' is enough for me. In other words, keeping field names to use them in INSERT requires some additional (and IMO unnecessary) work. Thanks for all answers and quick response. -- Marcin From charlie at egenix.com Wed Jan 5 15:08:05 2005 From: charlie at egenix.com (Charlie Clark) Date: Fri Mar 31 16:33:52 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <1577611449.20050105141214@tlen.pl> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> Message-ID: <20050105150805.21765.9@Zeta.1104914332.fake> On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > Hello Charlie, > > Tuesday, January 4, 2005, 7:45:04 PM, you wrote: > > > just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems > > that > > switching between encodings is what is upsetting the driver and as > > Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". > > MIXED_STRINGFORMAT changed nothing, the same error :( Well, it was just a suggestion... it's very difficult sometimes to pinpoint the exact problem without access to the same environment. As Marc-Andr? has written unicode support has improved in DBs and drivers but there are still lots of issues particularly in the drivers which we can't anticipate. > I found one more way to exec this query without change - > executedirect(). That's good to know. > > Just out of interest, what is wrong with: > > >> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ? > >> or use other cursor than used with None insert, but this sucks. > > > Surely, it is always better to explicitly relation attributes in queries? > > I have tables dynamically generated by app, I don't care for field > names, information like: 'first field is int, second ntext' is enough > for me. In other words, keeping field names to use them in INSERT > requires some additional (and IMO unnecessary) work. Okay, in that case. Interesting: you're using persistent storage for dynamic work? > Thanks for all answers and quick response. You're welcome Charlie -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From mal at egenix.com Wed Jan 5 18:02:38 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Mar 31 16:33:52 2006 Subject: [egenix-users] SQL Server 2000, mxODBC and unicode problem In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> References: <382760555.20050104171702@tlen.pl> <20050104194504.18453.14@Zeta.1104839330.fake> <1577611449.20050105141214@tlen.pl> <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: <41DC1DAE.4080108@egenix.com> Charlie Clark wrote: > On 2005-01-05 at 14:12:14 [+0100], Marcin wrote: > >>Hello Charlie, >> >>Tuesday, January 4, 2005, 7:45:04 PM, you wrote: >> >> >>>just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems >>>that >>>switching between encodings is what is upsetting the driver and as >>>Marc-Andr? has pointed out None will be passed as a non-unicode "NULL". >> >>MIXED_STRINGFORMAT changed nothing, the same error :( > > Well, it was just a suggestion... it's very difficult sometimes to pinpoint > the exact problem without access to the same environment. As Marc-Andr? has > written unicode support has improved in DBs and drivers but there are still > lots of issues particularly in the drivers which we can't anticipate. Another possible candidate is NATIVE_UNICODE_STRINGFORMAT. This will force mxODBC to pass the Unicode value as-is to the driver... >>I found one more way to exec this query without change - >>executedirect(). > > That's good to know. ...however, your findings really suggest that something is wrong with the driver. The difference between .execute() and .executedirect() is that the statements are not prepared for execution, but passed to the server more or less as-is (together with the parameters). The fact that .executedirect() works while .execute() doesn't suggests to me, that the driver is having a problem whereas the server can deal with the syntax just fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From Jim.Vickroy at noaa.gov Wed Jan 5 12:09:27 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Fri Mar 31 16:33:52 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: <20050105150805.21765.9@Zeta.1104914332.fake> Message-ID: Howdy, Could anyone offer a suggestion as to the cause of the following error: OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) when trying to perform a table insert operation? Some background: o The error is encountered by long-running processes after "some" period of time in which the inserts are successfully performed. o Once this error occurs, for a particular process, the same error persists until the process is stopped/restarted -- even though the process is coded to get a fresh connection each time it tries to do an insert to this table. o At the same time a process is experiencing the above error, it is able to successfully perform inserts and selects against other tables in a different SQL Server datastore. Some details: Microsoft Windows 2000 Server Microsoft SQL Server 2000 with all of the latest patches Python v2.3.3 egenix-mx-base-2.0.5.win32-py2.3 egenix-mx-commercial-2.0.6.win32-py2.3 Thanks, -- jv From mal at egenix.com Wed Jan 5 20:49:43 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Mar 31 16:33:52 2006 Subject: [egenix-users] OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server Driver]Communication link failure', 4612)',) In-Reply-To: References: Message-ID: <41DC44D7.4040909@egenix.com> Jim Vickroy wrote: > Howdy, > > Could anyone offer a suggestion as to the cause of the following error: > > OperationalError: ('08S01', 0, '[Microsoft][ODBC SQL Server > Driver]Communication link failure', 4612)',) > > when trying to perform a table insert operation? > > Some background: > > o The error is encountered by long-running processes after "some" period of > time in > which the inserts are successfully performed. > o Once this error occurs, for a particular process, the same error persists > until > the process is stopped/restarted -- even though the process is coded to > get > a fresh connection each time it tries to do an insert to this table. > o At the same time a process is experiencing the above error, it is able to > successfully > perform inserts and selects against other tables in a different SQL Server > datastore. It is possible that the connection timed out, e.g. due to periods of inactivity on the connection. You can adjust the connection time out (and many other settings) using: from mx.ODBC import Windows ... # Set connection timeout to 3600 seconds (= one hour) connection.setconnectoption(Windows.SQL.ATTR_CONNECTION_TIMEOUT, 3600) The full list of possible options is documented here (SQLSetConnectAttr function): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlsetconnectattr.asp All ODBC attributes IDs starting with "SQL_" are available via the special SQL lookup object that is exported by all the mxODBC subpackages. Many ODBC drivers also allow specifying the connection attributes in the connection DSN string in form of additional attributes. For SQL Server, these are documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > Some details: > > Microsoft Windows 2000 Server > Microsoft SQL Server 2000 with all of the latest patches > Python v2.3.3 > egenix-mx-base-2.0.5.win32-py2.3 > egenix-mx-commercial-2.0.6.win32-py2.3 -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 05 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Wed Jan 5 20:48:36 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Mar 31 16:33:52 2006 Subject: [egenix-users] ZmxODBC and DBFs Message-ID: <41DCC324.5020505@aviawest.com> Any tips on how to make a connection with an ODBC conneciton to DBF files? Thanks. From mal at egenix.com Thu Jan 6 10:42:12 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Mar 31 16:33:52 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DCC324.5020505@aviawest.com> References: <41DCC324.5020505@aviawest.com> Message-ID: <41DD07F4.1040400@egenix.com> Erik Myllymaki wrote: > Any tips on how to make a connection with an ODBC conneciton to DBF files? On Windows, you'd simply create a data source for the .dbf file. The MS MDAC package comes with ODBC drivers for .dbf files which can be used for this. The package is usually installed as part of MS Office, but also available separately from MS. I think that Win XP ships with the package preinstalled. It is also possible to create an ad-hoc connection using the FILEDSN connection string attribute... Connection parameters (DSNs): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp (scroll down to the comments section). A list of all the keywords you can use with MS SQL Server in the connection string: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp Example of a DSN-less connection string: "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" Example of a File DSN strings: "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From erik.myllymaki at aviawest.com Thu Jan 6 07:41:33 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Mar 31 16:33:52 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD07F4.1040400@egenix.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> Message-ID: <41DD5C2D.3070203@aviawest.com> Thanks for this. I made a file DSN entery in the ODBC manageer and it seems to work fine if my datasources are local (C: drive) but not if they are on a mapped drive. Any ideas on that one? M.-A. Lemburg wrote: > Erik Myllymaki wrote: > >> Any tips on how to make a connection with an ODBC conneciton to DBF >> files? > > > On Windows, you'd simply create a data source for the .dbf file. > The MS MDAC package comes with ODBC drivers for .dbf files which > can be used for this. The package is usually installed as part > of MS Office, but also available separately from MS. I think that > Win XP ships with the package preinstalled. > > It is also possible to create an ad-hoc connection using the > FILEDSN connection string attribute... > > Connection parameters (DSNs): > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp > > > (scroll down to the comments section). > > A list of all the keywords you can use with MS SQL Server in the > connection string: > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > > > Example of a DSN-less connection string: > > "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" > > Example of a File DSN strings: > > "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" > From erik.myllymaki at aviawest.com Thu Jan 6 08:15:07 2005 From: erik.myllymaki at aviawest.com (Erik Myllymaki) Date: Fri Mar 31 16:33:52 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD640B.1040602@aviawest.com> Figured it out; because the ODBC manager on WinXP doesn't allow you to type in a UNC path for the DBF directory, I had to set it up with a mapped drive letter, and then use regedit to change the mapped drive letter to UNC. Works fine now. Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? > > > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > eGenix.com User Mailing List http://www.egenix.com/ > http://lists.egenix.com/mailman/listinfo/egenix-users From mal at egenix.com Thu Jan 6 17:18:42 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Mar 31 16:33:52 2006 Subject: [egenix-users] ZmxODBC and DBFs In-Reply-To: <41DD5C2D.3070203@aviawest.com> References: <41DCC324.5020505@aviawest.com> <41DD07F4.1040400@egenix.com> <41DD5C2D.3070203@aviawest.com> Message-ID: <41DD64E2.3020008@egenix.com> Erik Myllymaki wrote: > Thanks for this. > > I made a file DSN entery in the ODBC manageer and it seems to work fine > if my datasources are local (C: drive) but not if they are on a mapped > drive. > > Any ideas on that one? No. I would assume that locking is not efficient enough to make this worthwhile. If you only want to read from the file, you could try to setup the connection as read-only. Some drivers support this using DSN connection string attributes and there's also a connection attribute for it... mxODBC.Windows.SQL.ATTR_ACCESS_MODE. This may also work on a mapped drive since it doesn't require locking. You may also want to try to use the network file names instead of the mapped driver file name to point to the file. That sometimes makes a difference. > > M.-A. Lemburg wrote: > >> Erik Myllymaki wrote: >> >>> Any tips on how to make a connection with an ODBC conneciton to DBF >>> files? >> >> >> >> On Windows, you'd simply create a data source for the .dbf file. >> The MS MDAC package comes with ODBC drivers for .dbf files which >> can be used for this. The package is usually installed as part >> of MS Office, but also available separately from MS. I think that >> Win XP ships with the package preinstalled. >> >> It is also possible to create an ad-hoc connection using the >> FILEDSN connection string attribute... >> >> Connection parameters (DSNs): >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqldriverconnect.asp >> >> >> (scroll down to the comments section). >> >> A list of all the keywords you can use with MS SQL Server in the >> connection string: >> >> >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp >> >> >> Example of a DSN-less connection string: >> >> "DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame" >> >> Example of a File DSN strings: >> >> "FILEDSN=HR_FDSN;UID=Smith;PWD=Sesame" >> > > > _______________________________________________________________________ > 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, Jan 06 2005) >>> 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,FreeBSD for free ! :::: From clozinski at Retailpro.com Tue Jan 11 16:07:07 2005 From: clozinski at Retailpro.com (Chris Lozinski) Date: Fri Mar 31 16:33:57 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) Message-ID: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> I am trying to install the mxODBCZopeDa product. I get the following detailed error message. This object is broken because the mxODBCZopeDA product that created it is no longer installed or is installed incorrectly. Please contact the product maintainer for assistance. Note that the data associated with this product has not been lost, and will be accessible again if the product is reinstalled. I have downloaded and installed both the base and commercial products into my root zope directory. It works on our production version of Windows, but is broken on the development site. Any ideas of what is going wrong. I would have expected this to be in the zope products directory, but evidently it only installs in the python directories. Regards Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050111/ea8d263b/attachment-0139.htm From mal at egenix.com Wed Jan 12 10:16:25 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Mar 31 16:33:57 2006 Subject: [egenix-users] (This object from the mxODBCZopeDA product is broken!) In-Reply-To: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> References: <7D790AD07FD933419801D3E3B8044F0F9D1F16@mail01.retailpro.com> Message-ID: <41E4EAE9.9040508@egenix.com> Chris Lozinski wrote: > I am trying to install the mxODBCZopeDa product. > > I get the following detailed error message. > > This object is broken because the mxODBCZopeDA product that created it > is no longer installed or is installed incorrectly. Please contact the > product maintainer for assistance. Please check the Zope log for details about the cause of the problem. There are a few things (among others) that could this: * the wrong version of mxODBC Zope DA was installed; note that this depends on the Python version you are using with Zope * the license files are not installed or damaged * the product ZIP archive was installed to the Zope instance directory; mxODBC Zope DA up to version 1.0.8 can only be installed to the Zope install directory (we'll fix this in 1.0.9) * there was already a version of egenix-mx-commercial installed in the system and Zope is picking up this wrong version > Note that the data associated with this product has not been lost, and > will be accessible again if the product is reinstalled. > > I have downloaded and installed both the base and commercial products > into my root zope directory. > > > > It works on our production version of Windows, but is broken on the > development site. > > > > Any ideas of what is going wrong. > > > > I would have expected this to be in the zope products directory, but > evidently it only installs in the python directories. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From lewicki at provider.pl Fri Jan 14 12:02:42 2005 From: lewicki at provider.pl (=?iso-8859-2?Q?Pawe=B3_Lewicki?=) Date: Fri Mar 31 16:33:57 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand Message-ID: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Hello, I have a problem with a connection on-demand I'm trying to establish. Is it possible to "automagically" free the connection after the query? I connect using that script: dbDA = getattr(self, 'myConnection') #mxODBCZopeDA dbConnection = dbDA.get_connection() dbConnection.query(SQL) An adapter is configured as 'on demand'. I tried to call manually .lazy_connect() and get working connection in different ways. The problem is that the connection stays open after the query. If I manually close it I have a problem with concurrent queries. I haven't done any long term tests so I don't know if the connecton is freed eventually. Is it configurable anywhere? Pawel Lewicki AP sp. z o.o. From mal at egenix.com Fri Jan 14 14:20:21 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Mar 31 16:33:57 2006 Subject: [egenix-users] mxODBCZopeDA - connection on demand In-Reply-To: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> References: <005501c4fa28$939bbeb0$b364a8c0@ksiegowa1> Message-ID: <41E7C715.1080502@egenix.com> Pawe? Lewicki wrote: > Hello, > I have a problem with a connection on-demand I'm trying to establish. Is it > possible to "automagically" free the connection after the query? > > I connect using that script: > > dbDA = getattr(self, 'myConnection') #mxODBCZopeDA > dbConnection = dbDA.get_connection() > dbConnection.query(SQL) > > > > An adapter is configured as 'on demand'. I tried to call manually > .lazy_connect() and get working connection in different ways. > > The problem is that the connection stays open after the query. If I manually > close it I have a problem with concurrent queries. Only the connect is done on demand. After the initial connect the connection will stay open. The feature is intended to reduce overhead when loading connection objects into memory. Most other DAs (re)open the connection when loading the connection object into memory - and this can happen even if you don't use the object at all. mxODBC Zope DA in on-demand connect mode will only open the connection if it is actually needed and used for a query. > I haven't done any long term tests so I don't know if the connecton is freed > eventually. Is it configurable anywhere? No, but we'll probably add something like this to one of the next releases. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From support at eGenix.com Fri Jan 14 19:00:11 2005 From: support at eGenix.com (Charlie Clark) Date: Fri Mar 31 16:33:57 2006 Subject: [egenix-users] Re: [egenix-info] mxODBCda and Stored Procedures In-Reply-To: <41E80211.7070204@inaugust.com> References: <41E80211.7070204@inaugust.com> Message-ID: <20050114190011.16359.17@Zeta.1105695510.fake> On 2005-01-14 at 18:32:01 [+0100], Monty Taylor wrote: > Hi, > > I have a client who is using mxODBCda and who uses stored procedures > under MS SQL Server across the enterprise. What would it take to support > stored procedures through mxODBCda? > > Thanks, > Monty Taylor Dear Monty, mxODBC already supports stored procedures through the callproc() method. Please see section 2.3.6 in the manual and let us know if you need support above and beyond this. Sincerely Charlie Clark -- Charlie Clark eGenix.com Professional Python Services directly from the Source >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:19:01 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Mar 31 16:33:57 2006 Subject: [egenix-users] Solid: OperationalError() Message-ID: <20050117141901.GA13248@foof.i3.cz> hello, i'm running egenix-mx-commercial version 2.1b02 (license bought), db engine is Solid 3.50. with python 2.2 everything runs correctly. however starting with python 2.3 inserting into a table gives the following error: OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, '10.0.0.122')& the error is raised when the application runs for a longish time (~24 hours) and _only_ when mxODBC is running over python 2.3+. what is the cause of the error? solid doesn't know anything about error code 08S01 or 5835. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 15:49:19 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Mar 31 16:33:57 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117141901.GA13248@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> Message-ID: <41EBD06F.3010404@egenix.com> Michal Vitecek wrote: > hello, > > i'm running egenix-mx-commercial version 2.1b02 (license bought), db > engine is Solid 3.50. with python 2.2 everything runs correctly. > however starting with python 2.3 inserting into a table gives the > following error: > > OperationalError ('08S01', 0, '', 5835): from /home/project/utils/db.py:503 for > query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, lastUsedTime, > ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, > '10.0.0.122')& > > the error is raised when the application runs for a longish time (~24 > hours) and _only_ when mxODBC is running over python 2.3+. what is the > cause of the error? solid doesn't know anything about error code 08S01 > or 5835. The first entry in the tuple is the SQL State value: 08S01 Communication link The communication link between the driver and failure the data source to which the driver was connected failed before the function completed processing. Even though there any many things that could cause such an error message, I'd suggest starting to check whether a firewall is blocking the TCP Port used by the server (e.g. as a result of an Win XP SP2 upgrade). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 15:56:12 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Mar 31 16:33:57 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBD06F.3010404@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> Message-ID: <20050117145612.GD13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >> hello, >> >> i'm running egenix-mx-commercial version 2.1b02 (license bought), db >> engine is Solid 3.50. with python 2.2 everything runs correctly. >> however starting with python 2.3 inserting into a table gives the >> following error: >> >>OperationalError ('08S01', 0, '', 5835): from >>/home/project/utils/db.py:503 for >>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>lastUsedTime, >>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>'10.0.0.122')& >> >> the error is raised when the application runs for a longish time (~24 >> hours) and _only_ when mxODBC is running over python 2.3+. what is the >> cause of the error? solid doesn't know anything about error code 08S01 >> or 5835. > >The first entry in the tuple is the SQL State value: > >08S01 Communication link The communication link between the >driver and > failure the data source to which the driver > was > connected failed before the function > completed > processing. > >Even though there any many things that could cause such >an error message, I'd suggest starting to check whether a firewall >is blocking the TCP Port used by the server (e.g. as a result of >an Win XP SP2 upgrade). i'm running this on Slackware 10.0, no firewall is present on that computer and the communication is done via unix sockets. so this doesn't seem like the problem. also the computer i'm running it on is not loaded at all (184 processes, load average 0.00, file-nr 1389 91 52313). again this doesn't happen with python 2.2 (at least it hasn't for 2 years). there's nothing in the solid's error or message log. thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:20:59 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Mar 31 16:33:57 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117145612.GD13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> Message-ID: <41EBE5EB.5060303@egenix.com> Michal Vitecek wrote: > M.-A. Lemburg wrote: > >>Michal Vitecek wrote: >> >>>hello, >>> >>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>however starting with python 2.3 inserting into a table gives the >>>following error: >>> >>>OperationalError ('08S01', 0, '', 5835): from >>>/home/project/utils/db.py:503 for >>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>lastUsedTime, >>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>'10.0.0.122')& >>> >>>the error is raised when the application runs for a longish time (~24 >>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>cause of the error? solid doesn't know anything about error code 08S01 >>>or 5835. >> >>The first entry in the tuple is the SQL State value: >> >>08S01 Communication link The communication link between the >>driver and >> failure the data source to which the driver >> was >> connected failed before the function >> completed >> processing. >> >>Even though there any many things that could cause such >>an error message, I'd suggest starting to check whether a firewall >>is blocking the TCP Port used by the server (e.g. as a result of >>an Win XP SP2 upgrade). > > i'm running this on Slackware 10.0, no firewall is present on that > computer and the communication is done via unix sockets. so this > doesn't seem like the problem. also the computer i'm running it on is > not loaded at all (184 processes, load average 0.00, file-nr 1389 91 > 52313). > > again this doesn't happen with python 2.2 (at least it hasn't for 2 > years). there's nothing in the solid's error or message log. There shouldn't be any differences between Python 2.2 and 2.3 versions of mxODBC. However, it is possible that the versions you compiled pick up different drivers or configuration files. The error you are seeing is generated by the ODBC driver not mxODBC and the result of executing the statement (not the prepare or binding step). If you're using domain sockets, please also check the permissions on the socket "files". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From fuf at mageo.cz Mon Jan 17 17:42:13 2005 From: fuf at mageo.cz (Michal Vitecek) Date: Fri Mar 31 16:33:57 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <41EBE5EB.5060303@egenix.com> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> Message-ID: <20050117164213.GI13270@foof.i3.cz> M.-A. Lemburg wrote: >Michal Vitecek wrote: >>M.-A. Lemburg wrote: >> >>>Michal Vitecek wrote: >>> >>>>hello, >>>> >>>>i'm running egenix-mx-commercial version 2.1b02 (license bought), db >>>>engine is Solid 3.50. with python 2.2 everything runs correctly. >>>>however starting with python 2.3 inserting into a table gives the >>>>following error: >>>> >>>>OperationalError ('08S01', 0, '', 5835): from >>>>/home/project/utils/db.py:503 for >>>>query: INSERT INTO userAuthStr (userId, authStr, isUnconfirmed, >>>>lastUsedTime, >>>>ip) VALUES (0, '08a3db2fc1b13549bd125f265d30b808', 0, 1105972868, >>>>'10.0.0.122')& >>>> >>>>the error is raised when the application runs for a longish time (~24 >>>>hours) and _only_ when mxODBC is running over python 2.3+. what is the >>>>cause of the error? solid doesn't know anything about error code 08S01 >>>>or 5835. >>> >>>The first entry in the tuple is the SQL State value: >>> >>>08S01 Communication link The communication link between the >>>driver and >>> failure the data source to which the driver >>> was >>> connected failed before the function >>> completed >>> processing. >>> >>>Even though there any many things that could cause such >>>an error message, I'd suggest starting to check whether a firewall >>>is blocking the TCP Port used by the server (e.g. as a result of >>>an Win XP SP2 upgrade). >> >> i'm running this on Slackware 10.0, no firewall is present on that >> computer and the communication is done via unix sockets. so this >> doesn't seem like the problem. also the computer i'm running it on is >> not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >> 52313). >> >> again this doesn't happen with python 2.2 (at least it hasn't for 2 >> years). there's nothing in the solid's error or message log. > >There shouldn't be any differences between Python 2.2 and 2.3 >versions of mxODBC. However, it is possible that the versions >you compiled pick up different drivers or configuration files. i have egenix-mx-commercial 2.1b02 which uses the old way of configuration (one has to edit the mxCOMMERCIAL.py file). there's only one Solid library on that computer. also there's only python 2.4 installed, but it behaves the same with python 2.3 even though doesn't with python 2.2. >The error you are seeing is generated by the ODBC driver not >mxODBC and the result of executing the statement (not the prepare >or binding step). >If you're using domain sockets, please also check the permissions >on the socket "files". the permissions are right for sure - as i said - the application (a server actually with each thread having its own database handle) runs all okay for like ~24 hours, then it begins spitting these OperationalError() exceptions and no connection to the database is possible. the only thing that comes to my mind is whether this could be caused by the Solid engine closing the connection because there isn't going on much at the time (the machine is not used most of the time). but mxODBC should be able to catch this kind of problem and report it, right? i'm using my own wrapper around direct calls to mxODBC and before each execute() a test on valid connection is performed, so the code looks like: ... if (self.__db.closed): self.__reconnect() try: retVal = self.__cursor.execute(queryString) ... so self.__db.closed should be set when it is a connecion problem i guess. p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new system of configuration is less understandable for me :/ thanks, -- fuf (fuf@mageo.cz) From mal at egenix.com Mon Jan 17 17:54:31 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Mar 31 16:33:57 2006 Subject: [egenix-users] Solid: OperationalError() In-Reply-To: <20050117164213.GI13270@foof.i3.cz> References: <20050117141901.GA13248@foof.i3.cz> <41EBD06F.3010404@egenix.com> <20050117145612.GD13270@foof.i3.cz> <41EBE5EB.5060303@egenix.com> <20050117164213.GI13270@foof.i3.cz> Message-ID: <41EBEDC7.9050005@egenix.com> Michal Vitecek wrote: >>>>08S01 Communication link The communication link between the >>>>driver and >>>> failure the data source to which the driver >>>> was >>>> connected failed before the function >>>> completed >>>> processing. >>>> >>>>Even though there any many things that could cause such >>>>an error message, I'd suggest starting to check whether a firewall >>>>is blocking the TCP Port used by the server (e.g. as a result of >>>>an Win XP SP2 upgrade). >>> >>>i'm running this on Slackware 10.0, no firewall is present on that >>>computer and the communication is done via unix sockets. so this >>>doesn't seem like the problem. also the computer i'm running it on is >>>not loaded at all (184 processes, load average 0.00, file-nr 1389 91 >>>52313). >>> >>>again this doesn't happen with python 2.2 (at least it hasn't for 2 >>>years). there's nothing in the solid's error or message log. >> >>There shouldn't be any differences between Python 2.2 and 2.3 >>versions of mxODBC. However, it is possible that the versions >>you compiled pick up different drivers or configuration files. > > > i have egenix-mx-commercial 2.1b02 which uses the old way of > configuration (one has to edit the mxCOMMERCIAL.py file). there's only > one Solid library on that computer. also there's only python 2.4 > installed, but it behaves the same with python 2.3 even though doesn't > with python 2.2. > >>The error you are seeing is generated by the ODBC driver not >>mxODBC and the result of executing the statement (not the prepare >>or binding step). > > > >>If you're using domain sockets, please also check the permissions >>on the socket "files". > > > the permissions are right for sure - as i said - the application (a > server actually with each thread having its own database handle) runs > all okay for like ~24 hours, then it begins spitting these > OperationalError() exceptions and no connection to the database is > possible. > > the only thing that comes to my mind is whether this could be caused > by the Solid engine closing the connection because there isn't going on > much at the time (the machine is not used most of the time). but mxODBC > should be able to catch this kind of problem and report it, right? mxODBC does report the problem (after all, you are getting an exception back). Sounds like you running into a timeout problem. Solid does allow setting a connection timeout, but according to their docs, this timeout only applies to the TCP connections. > i'm using my own wrapper around direct calls to mxODBC and before each > execute() a test on valid connection is performed, so the code looks > like: > > ... > > if (self.__db.closed): > self.__reconnect() > > try: > retVal = self.__cursor.execute(queryString) > ... > > so self.__db.closed should be set when it is a connecion problem i > guess. That flag is only set, if you explicitly close the connection by calling .close(). There's no generic way of checking whether the connection still is alive. In ODBC 3.5 MS introduced a new connection attribute SQL.ATTR_CONNECTION_ALIVE which you could try to use, but this is not widely support among ODBC drivers yet. I usually use dummy SQL statements to test for connectivity or simply issue a .rollback() on the connection before starting to process a new request. > p.s.: i would use 2.0.6 but i wasn't even able to compile it - the new > system of configuration is less understandable for me :/ You might want to try using an ODBC manager between mxODBC and the Solid ODBC driver. Such setups are usually much easier to administer and maintain (even if there's a small performance cost to pay). -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 10 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 14:41:36 2005 From: moof at metamoof.net (Moof) Date: Fri Mar 31 16:33:57 2006 Subject: [egenix-users] problems with MSSQL Server functions Message-ID: <41F10690.40104@metamoof.net> Hi, I seem to have a slight problem with MSSQL server. c is a cursor to an SQL Server instance: c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) gives me the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\...\hoteltypes.py", line 153, in getBestRates rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) File "C:\...\DB.py", line 93, in _getBestRates (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid parameter number', 4504) for the record, at this point: fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = 0, idHotel = 1 (fromDate and toDate were mx.DateTime instances, but I changed them to COM dates just in case that was the issue) I'm a bit stumped as to why I'm getting this error. Any ideas? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 14:49:47 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Mar 31 16:33:57 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F10690.40104@metamoof.net> References: <41F10690.40104@metamoof.net> Message-ID: <41F1087B.7010304@egenix.com> Moof wrote: > Hi, > > I seem to have a slight problem with MSSQL server. > > c is a cursor to an SQL Server instance: > > c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) This doesn't look like valid SQL to me. Could you explain what the function does and what "tab" is for ? > gives me the following error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\...\hoteltypes.py", line 153, in getBestRates > rates = self._getBestRates(fromDate, toDate, idRegimen, idRoom) > File "C:\...\DB.py", line 93, in _getBestRates > (fromDate, toDate, self.idCorp, idRoom, idRegimen, self.idHotel)) > InternalError: ('S1093', 0, '[Microsoft][ODBC SQL Server Driver]Invalid > parameter number', 4504) > > for the record, at this point: > > fromDate = 38373.0, toDate = 38377.0, idCorp = -1, idRoom = -1, idRegimen = > 0, idHotel = 1 > > (fromDate and toDate were mx.DateTime instances, but I changed them to COM > dates just in case that was the issue) > > I'm a bit stumped as to why I'm getting this error. Any ideas? > > Moof -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 18:08:34 2005 From: moof at metamoof.net (Moof) Date: Fri Mar 31 16:33:57 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F13712.6090000@metamoof.net> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? The above was sent privately, as I was expectign a rpley to go directly to the list, and it didn't. FWIW, I tried executedirect() which works flawlessly. So it must have something to do with whatever it is that execute() does differently to executedirect(). Given that all I'm doing is calling a function which does all the hard work, I expect I won't get much of a performace gain out of execute() in this case. But I'm still intrigued as to why one works and the other doesn't. Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Fri Jan 21 18:08:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Mar 31 16:33:57 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F11D5E.8030500@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> Message-ID: <41F1371D.5000402@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > >>Moof wrote: >> >> >>>Hi, >>> >>>I seem to have a slight problem with MSSQL server. >>> >>>c is a cursor to an SQL Server instance: >>> >>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>self.idHotel)) >> >> >>This doesn't look like valid SQL to me. Could you explain what the >>function does and what "tab" is for ? > > > Copied straight out of my enterprise manager query section: > > SELECT * > FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab > > which returned a valid table with the data I'm after. > > Microsoft's SQL Server seems intent on removing AS from that. It should be > GetBestRates_Moof(..) AS tab, just to give it an easier name for later > reference as tab.Day, tab.RPax, etc. Either way, it gives the same error > *without* the tab bit. > > GetBestRates_Moof is a user defined function that takes two smaldatetimes > and four ints and returns a table with columns made up of a smalldatettime, > 5 ints, 3 floats and another int. It's a complex query that calculates the > cheapest rate for a given range of days in one of the various hotels we're > running. > > Does that help? Well in standard SQL you would probably want to specify the table name somewhere and from the function into the SELECT clause: SELECT GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) as tab FROM some_table If the function does indeed return a table name, then you cannot use bind parameters for it. This is not allowed in ODBC. The only way to solve the issue then is to quote the parameters and place them into the statement string as SQL literals (like in the above example). More infos on where bind parameters are allowed in ODBC: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcparameter_markers.asp -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From mal at egenix.com Fri Jan 21 18:17:28 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Mar 31 16:33:57 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13712.6090000@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> Message-ID: <41F13928.5060509@egenix.com> Moof wrote: > Moof wrote: > >>M.-A. Lemburg wrote: >> >> >>>Moof wrote: >>> >>> >>> >>>>Hi, >>>> >>>>I seem to have a slight problem with MSSQL server. >>>> >>>>c is a cursor to an SQL Server instance: >>>> >>>>c.execute('SELECT * FROM GetBestRates_Moof( ?, ?, ?, ?, ?, ? ) tab', >>>> (fromDate, toDate, self.idCorp, idRoom, idRegimen, >>>>self.idHotel)) >>> >>> >>>This doesn't look like valid SQL to me. Could you explain what the >>>function does and what "tab" is for ? >> >> >>Copied straight out of my enterprise manager query section: >> >>SELECT * >>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, 1) tab >> >>which returned a valid table with the data I'm after. >> >>Microsoft's SQL Server seems intent on removing AS from that. It should be >>GetBestRates_Moof(..) AS tab, just to give it an easier name for later >>reference as tab.Day, tab.RPax, etc. Either way, it gives the same error >>*without* the tab bit. >> >>GetBestRates_Moof is a user defined function that takes two smaldatetimes >>and four ints and returns a table with columns made up of a smalldatettime, >>5 ints, 3 floats and another int. It's a complex query that calculates the >>cheapest rate for a given range of days in one of the various hotels we're >>running. >> >>Does that help? > > > The above was sent privately, as I was expectign a rpley to go directly to > the list, and it didn't. > > FWIW, I tried executedirect() which works flawlessly. So it must have > something to do with whatever it is that execute() does differently to > executedirect(). Makes sense: .executedirect() sends the command directly to the server. It doesn't prepare the command for execution first, which .execute() does in order to be able to cache the preparation step for subsequent calls with different parameters. I still wonder why the server doesn't complain, though. I've never seen a database that allows using table selection based on bound parameters and this is actually the first time I've seen a stored procedure being used to determine the table name. > Given that all I'm doing is calling a function which does all the hard work, > I expect I won't get much of a performace gain out of execute() in this > case. But I'm still intrigued as to why one works and the other doesn't. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From moof at metamoof.net Fri Jan 21 19:34:15 2005 From: moof at metamoof.net (Moof) Date: Fri Mar 31 16:33:57 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F13928.5060509@egenix.com> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> Message-ID: <41F14B27.8050206@metamoof.net> M.-A. Lemburg wrote: >>> SELECT * >>> FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>> 1) tab > Makes sense: .executedirect() sends the command directly to the > server. It doesn't prepare the command for execution first, which > .execute() does in order to be able to cache the preparation > step for subsequent calls with different parameters. > > I still wonder why the server doesn't complain, though. I've > never seen a database that allows using table selection based > on bound parameters and this is actually the first time I've > seen a stored procedure being used to determine the table > name. Sorry, no, I didn't explain correctly. GetBestRates_Moof returns a set of results, which to all intents and purposes *is* a table, and can be queried as if it were one. Think of it as a bounded view that is generated on the fly. I cannot have a permanent view defined for this data due to the rather horrid database design that I have to live with for the moment. I don't need to or want to calculate the lowest rates for every single day in the entirety of time, which is what I'd have to do with a view, so instead I generate it for the number of days defined in the interval (which above is 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function creates the range of dates as a resultset and promptly joins it to a bunch of other complicated stuff. I find working with dates the most taxing thing abotu this particular database, especially as sometimes I'm working on real time, and sometimes I'm working on the defined date. If you check in at 1am on the 23rd, say, it still has to be counted as if you checked in on the 22nd for accounting and availability purposes as you're still sleeping the night in the hotel and need to be charged for it. The day switches over once close of business has been declared by the receptionist, which is about 5am for most of our hotels. Anyway, that's just me blathering on. Does it still make sense as to why execute() isn't doing the right thing? surely it should return an error more akin to "command cannot be prepared" or something? Moof -- Giles Antonio Radford - Website down, but take a peek at http://del.icio.us/moof/ Homme petit d'homme petit, s'attend, n'avale / Homme petit d'homme petit, ? degr?s de b?gues folles / Anal deux qui noeuds ours, anal deux qui noeuds s'y m?nent / Coup d'un poux tome petit tout guetteur ? gaine - Who was badly hurt? From mal at egenix.com Mon Jan 24 14:04:39 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Mar 31 16:33:57 2006 Subject: [egenix-users] problems with MSSQL Server functions In-Reply-To: <41F14B27.8050206@metamoof.net> References: <41F10690.40104@metamoof.net> <41F1087B.7010304@egenix.com> <41F11D5E.8030500@metamoof.net> <41F13712.6090000@metamoof.net> <41F13928.5060509@egenix.com> <41F14B27.8050206@metamoof.net> Message-ID: <41F4F267.1070103@egenix.com> Moof wrote: > M.-A. Lemburg wrote: > > >>>>SELECT * >>>>FROM GetBestRates_Moof('20050121', '20050127', - 1, - 1, 0, >>>>1) tab > > >>Makes sense: .executedirect() sends the command directly to the >>server. It doesn't prepare the command for execution first, which >>.execute() does in order to be able to cache the preparation >>step for subsequent calls with different parameters. >> >>I still wonder why the server doesn't complain, though. I've >>never seen a database that allows using table selection based >>on bound parameters and this is actually the first time I've >>seen a stored procedure being used to determine the table >>name. > > > Sorry, no, I didn't explain correctly. > > GetBestRates_Moof returns a set of results, which to all intents and > purposes *is* a table, and can be queried as if it were one. Think of it as > a bounded view that is generated on the fly. > > I cannot have a permanent view defined for this data due to the rather > horrid database design that I have to live with for the moment. I don't need > to or want to calculate the lowest rates for every single day in the > entirety of time, which is what I'd have to do with a view, so instead I > generate it for the number of days defined in the interval (which above is > 2005-01-21 to 2005-01-27). In fact, internally, it appears that the function > creates the range of dates as a resultset and promptly joins it to a bunch > of other complicated stuff. > > I find working with dates the most taxing thing abotu this particular > database, especially as sometimes I'm working on real time, and sometimes > I'm working on the defined date. If you check in at 1am on the 23rd, say, it > still has to be counted as if you checked in on the 22nd for accounting and > availability purposes as you're still sleeping the night in the hotel and > need to be charged for it. The day switches over once close of business has > been declared by the receptionist, which is about 5am for most of our hotels. > > Anyway, that's just me blathering on. Thanks for the background infos. > Does it still make sense as to why execute() isn't doing the right thing? > surely it should return an error more akin to "command cannot be prepared" > or something? I guess this is a quirk in the MS SQL ODBC driver. The error message doesn't contain enough information to be able to tell what is going wrong, e.g. it is possible the the driver simply ignores the ?-mark parameters in the statement and thus assumes that the number of parameters is 0 rather than 6. Just guessing here... for a complete analysis, you'd have to run mxODBC in a debugger. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 20 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Sun Jan 30 16:24:33 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Fri Mar 31 16:33:58 2006 Subject: [egenix-users] Windows ODBC DataSource Names Message-ID: 1. Is there a way to define an ODBC Datasource in Windows, such that one can specify the database name at the time the connection is requested? 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? http://egenix.com/files/python/mxODBC.html#Examples Shouldn't you get "NameError: name 'mx' is not defined" Thanks Bob-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050130/4d30a976/attachment-0139.htm From mal at egenix.com Sun Jan 30 22:46:52 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Mar 31 16:33:58 2006 Subject: [egenix-users] Windows ODBC DataSource Names In-Reply-To: References: Message-ID: <41FD55CC.20108@egenix.com> Bob Gibson wrote: > > > > 1. Is there a way to define an ODBC Datasource in Windows, such that one > can > specify the database name at the time the connection is requested? It is possible to connect to data source that are not configured in the ODBC manager by defining the data source in the connection string, provided that you know the name of ODBC driver: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcconnecting_directly_to_drivers.asp Example: db = mx.ODBC.Windows("DRIVER={SQL Server};SERVER=hrserver;UID=Smith;PWD=Sesame") cursor = db.cursor() ... This example is for the MS SQL Server. More information is available at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_4x4k.asp > 2. How could the "mx.ODBC.print_resultset(c)" on you examples page work? > > http://egenix.com/files/python/mxODBC.html#Examples > > Shouldn't you get "NameError: name 'mx' is not defined" Indeed. Those examples were copied from an interactive session and it looks as if we forgot the "import mx.ODBC" in the printout. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 28 2005) >>> 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,FreeBSD for free ! :::: From YBreuer at tee.toshiba.de Mon Jan 31 11:27:07 2005 From: YBreuer at tee.toshiba.de (Breuer, Yvon) Date: Fri Mar 31 16:33:58 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope Message-ID: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Hello to all members of the list, I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. Thank you in advance for your support. Best regards, Yvon Breuer ********************************************************************** CONFIDENTIALITY DISCLAIMER The information in this email and in any attachments is confidential and may be privileged. If you are not the intended recipient, please destroy this message, delete any copies held on your systems and notify the sender immediately. You should not retain, copy or use this email for any purpose outside of any NDA currently existing between Toshiba Electronics Europe GmbH and yourselves. ********************************************************************** From mal at egenix.com Mon Jan 31 12:12:45 2005 From: mal at egenix.com (M.-A. Lemburg) Date: Fri Mar 31 16:33:58 2006 Subject: [egenix-users] Accessing tables from a Python script in Zope In-Reply-To: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> References: <761F1C437287E6429C2C04EFB6DD5BE9106F2F@ex03.tsb-eu.com> Message-ID: <41FE12AD.1080801@egenix.com> Breuer, Yvon wrote: > Hello to all members of the list, > > I recently installed the mxODBCZopeDA and when I test it via the test tab everything works fine. A test via DTML worked fine too. Then I wanted to be more flexible so I added dtml-var's and again it worked just fine. But... ;-) > > I want to be completely free in how I built my SQL string. And I'd rather do this directly from a Python script in Zope instead of using a ZSQL Method. I need to be this flexible because I do not know which table I have to read and which fields I have to select before I start. Final goal is to copy data from one system to the other. So therefore I've got two eGenix mxODBC Database Connections in my root folder which I called SYS1 and SYS2. The ZSQL Methods I defined are ZSQLSYS1 and ZSQLSYS2. (How obvious ;) > > Enough background info, the question is: How can I execute a SQL statement from a Python script in Zope? I tried the sample coding from the Examples chapter in the mxODBC.pdf (in several ways), but this always resulted in an error. You can do this by setting up one or more External Methods: http://www.zope.org/Documentation/How-To/ExternalMethods These method then have access to the connection objects. To get access to a (physical) connection, simply call the connection object. The Zope DA will then retun a DatabaseConnection object which has among others, a method called .query(). You can call this method with an SQL statement and it will return the results in form of a tuple (columns, rowset) with columns being a Zope specific list of dictionaries describing the column types and rowset a list of row tuples (in the order given in the columns definition). If you want to use bind parameters (? as place holders in the SQL), you can also call the .execute() or .executemany() methods on the DatabaseConnection (see the documentation for details). Finally, if you want to bypass Zope completely, you can import mxODBC directly in the external method and use its interface. However, this is not recommended, since this also bypasses the Zope transaction interface and could thus lead to data corruption. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 31 2005) >>> 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,FreeBSD for free ! :::: From bgibson at us.ibm.com Mon Jan 31 22:32:12 2005 From: bgibson at us.ibm.com (Bob Gibson) Date: Fri Mar 31 16:33:58 2006 Subject: [egenix-users] mxODBC - How do I "set schema"? Message-ID: Hi: I'm working with mxODBC, and have successfully connected to my database. This is the good news. :-) When I try to "set schema" though, I get a -1 return value. What, exactly, does this mean? What am I doing wrong? ---------------------------------------------------------------------- C:\Programs\Python\Python2Derby>python ActivePython 2.4 Build 243 (ActiveState Corp.) based on Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mx.ODBC as ODBC >>> DB = ODBC.Windows >>> db = DB.DriverConnect( 'DSN=Derby;UID=IMA;PWD=Lumberjack;DBALIAS=sq4mm' ) >>> cursor = db.cursor() >>> cursor.execute( "select count(*) from sys.systables" ) >>> for field in cursor.description : ... print field ... ('1', 4, None, None, 10, 0, 0) >>> data = cursor.fetchall() >>> for row in data : ... print row ... (58,) >>> cursor.execute( "set schema school" ) -1 >>> ---------------------------------------------------------------------- By the way, I know that the schema name is correct. I created the database, the tables, and all the schema names. Here's a sample DB2CLP session that shows the same command executing successfully. ---------------------------------------------------------------------- db2 => connect to sq4mm user Ima using Lumberjack Database Connection Information Database server = Apache Derby CSS10000 SQL authorization ID = IMA Local database alias = SQ4MM db2 => select count(*) from sys.systables 1 ----------- 58 1 record(s) selected. db2 => set schema school DB20000I The SQL command completed successfully. db2 => ---------------------------------------------------------------------- Thanks in advance Bob Ps 37:16 It is better to be godly and have little than to be evil and possess much.-------------- next part -------------- An HTML attachment was scrubbed... URL: /mailman-archives/egenix-users/attachments/20050131/ad27ead9/attachment-0139.htm